zoukankan      html  css  js  c++  java
  • aspose.cell 设置excel里面的文字是超链接

    目的:

    1.通过方法designer.Workbook.Worksheets[0].Hyperlinks.Add("A1", 1, 1, url);给导出到excel里面的数据加上超链接

    2.使用mvc进行测试

    3.给A1,A2两个单元格加上超链接

    4.给超链接加上超链接样式

    5.添加超链接有2个方法

    public int Add(string cellName, int rowNumber, int columnNumber, string address);
    public int Add(int firstRow, int firstColumn, int rowNumber, int columnNumber, string address);

    具体实现核心方法:

    designer.Workbook.Worksheets[0].Cells[0, 0].PutValue("超链接1");

    designer.Workbook.Worksheets[0].Cells[1, 0].PutValue("超链接2");

    designer.Workbook.Worksheets[0].Hyperlinks.Add("A1", 1, 1, url);
    designer.Workbook.Worksheets[0].Cells[0, 0].SetStyle(LinkStyle(designer.Workbook));

    designer.Workbook.Worksheets[0].Hyperlinks.Add(1, 0, 1, 1, url);
    designer.Workbook.Worksheets[0].Cells[1, 0].SetStyle(LinkStyle(designer.Workbook));

    效果图

    入口方法

      public ActionResult chaolianjie()
            {
                string url = "http://www.baidu.com/";
                WorkbookDesigner designer = new WorkbookDesigner();
                string path = Server.MapPath("/Templete/DDD.xls");
                designer.Workbook.Open(path);
                //添加超链接
                designer.Workbook.Worksheets[0].Cells[0, 0].PutValue("超链接1");
                designer.Workbook.Worksheets[0].Cells[1, 0].PutValue("超链接2");
                designer.Workbook.Worksheets[0].Hyperlinks.Add("A1", 1, 1, url);
                designer.Workbook.Worksheets[0].Cells[0, 0].SetStyle(LinkStyle(designer.Workbook));
    
                designer.Workbook.Worksheets[0].Hyperlinks.Add(1, 0, 1, 1, url);
                designer.Workbook.Worksheets[0].Cells[1, 0].SetStyle(LinkStyle(designer.Workbook));
                designer.Process();
    
                //将流文件写到客户端流的形式写到客户端,名称是_report.xls
                designer.Save("_report.xls", SaveType.OpenInExcel, FileFormatType.Excel2003, System.Web.HttpContext.Current.Response);
                Response.Flush();
                Response.Close();
                designer = null;
                // Response.End();
                return View("getexcel");
            }
    
  • 相关阅读:
    Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 1
    架构-MVVM:MVVM核心概念
    架构-MVVC:百科
    架构:目录
    架构:template
    JavaScript-Tool:Ext JS
    JavaScript-Tool:jquery.tree.js-un
    JavaScript-Tool:wdtree
    C#:C# 运算符
    C#:目录
  • 原文地址:https://www.cnblogs.com/muer/p/asposecellHyperlinks.html
Copyright © 2011-2022 走看看