Tag: excellibrary

如何在vb.net中使用MVC 4中的控制器创build并返回Excel文件?

我正在使用ExcelLibrary 在这里input链接描述,因为我不想安装Microsoft Office Excel(microsoft.interop.office.excel) Public Function ObtenerExcel() As ActionResult Dim workbook As New Workbook() Dim worksheet As New Worksheet("Sheet1") worksheet.Cells(5, 5) = New Cell(999999) worksheet.Cells(10, 10) = New Cell(12354) workbook.Worksheets.Add(worksheet) Dim stream As New System.IO.MemoryStream workbook.SaveToStream(stream) stream.Position = 0 Dim buffer(4096) As Byte stream.Read(buffer, 0, buffer.Length) Return File(buffer, "application/vnd.ms-excel", "mytestfile.xls") End Function 此代码返回一个excel文件,但是当我尝试打开这个文件时,它显示一个错误消息(Excel在'text.xls'中发现了不可读的内容。你想恢复这个工作簿的内容吗?如果你相信此工作簿,单击是。),它不显示任何内容。 我在Windows 8.1(64位)和Microsoft […]

如何使用DataTable和ExcelLibrary创buildExcel工作表?

我有数据表,其中不包含任何列的date与“date”数据types。 我试过下面的选项 1)第三部分DLL- ExcelLibrary如果数据集中没有date列,那么它工作正常,否则它会使用一些类似-65284的虚拟值而不是date。 ExcelLibrary.DataSetHelper.CreateWorkbook(@"C:\Users\ABC\Documents\Excel\Report123.xls", ds); 2)使用简单的导出格式而不使用第三方DLL public void ExportToExcel(System.Data.DataTable dt) { if (dt.Rows.Count > 0) { string filename = "Report123.xls"; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); DataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dt; dgGrid.DataBind(); //Get the HTML for the control. dgGrid.RenderControl(hw); //Write the HTML back to the browser. //Response.ContentType […]

如何使用ExcelLibrary DLL在Excel中冻结页眉行

我正在使用ExcelLibrary DLL。 我想冻结标题行..任何机构可以build议我怎么可以做到这一点? 我已经尝试了下面的代码 Imports System.Data.SqlClient Imports ExcelLibrary Imports ExcelLibrary.SpreadSheet Partial Class DownloadExcel Inherits System.Web.UI.Page Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Try Dim wb As New Workbook() Dim sheetrowcounter As Integer sheetrowcounter = 0 Dim sheet As New ExcelLibrary.SpreadSheet.Worksheet("ExcelSheet") sheet.Cells(sheetrowcounter, 0) = New Cell("DELIVERY MONITORING SUMMARY(PROJECT GRANDE) ") sheet.Cells(sheetrowcounter, 2) = […]

无法打开使用excelLibrary生成的excel文件

我正在使用excelLibrary以编程方式创buildexcel文件,但当我尝试在Microsoft Office Excel中打开生成的文件时出现文件格式错误。 我已经看到这个报道,但仍然没有答案。 我使用Office 2010,我可以打开任何其他.xls(97-2003文件格式),但使用excelLibrary生成的。 我也试过Open Office,仍然无法打开生成的文件。 我还没有试图在Office 97-2003中打开它们。 试试这个示例代码来重现错误。 有没有人发现如何使用库,而不是遇到这个问题?