closedxml

ClosedXML - Creating multiple pivot tables

99封情书 提交于 2020-01-12 12:48:48
问题 I am trying to export some data to an excel sheet S1 whose data would be shown as Pivoted views in the next two sheets S2 and S3 . I am able to create a single pivot and it works perfect. But when I create two pivots, the consequent Excel file renders as corrupt. By corrupt I mean, On clicking yes, I get this - Here is the code I am using to create the pivots - using XL = ClosedXML.Excel; ... XL.XLWorkbook wb = new XL.XLWorkbook(); dsData = Session["ExportData"] as DataSet; var sheet1 = wb

ClosedXML - Creating multiple pivot tables

烈酒焚心 提交于 2020-01-12 12:45:47
问题 I am trying to export some data to an excel sheet S1 whose data would be shown as Pivoted views in the next two sheets S2 and S3 . I am able to create a single pivot and it works perfect. But when I create two pivots, the consequent Excel file renders as corrupt. By corrupt I mean, On clicking yes, I get this - Here is the code I am using to create the pivots - using XL = ClosedXML.Excel; ... XL.XLWorkbook wb = new XL.XLWorkbook(); dsData = Session["ExportData"] as DataSet; var sheet1 = wb

OutOfMemory errors using large datatables with ClosedXML

风流意气都作罢 提交于 2020-01-07 02:57:13
问题 I have an issue creating worksheets when adding large DataTables. I am getting out of memory errors. I turned off the event tracking as suggested to improve performance and memory consumption but I am still experiencing these errors. Here is some sample code: public void SaveWorkBook(string xlFileName, DataSet dataSet) { using (var xlWorkBook = new XLWorkbook(XLEventTracking.Disabled)) { xlWorkBook.AddWorksheet(dataSet); xlWorkBook.SaveAs(xlFileName); } } public void SaveWorkBook(string

ClosedXML add image

给你一囗甜甜゛ 提交于 2020-01-02 07:17:28
问题 I am able to add in an image to an excel spreadsheet by using OpenXML. However for the rest of the program I use ClosedXML to add data. I can add data at a specific cell using the column and row index. If I can add an image to an excel (It currently is a separate layer it seems, hovering over cells), how can I add it to a cell using ClosedXML? //Adds an image to the excel file public void AddImageToExcel(SpreadsheetDocument sd, MemoryStream imagestream) { DrawingsPart dp = sd.WorkbookPart

How to use a gradient fill (GradientFill) with ClosedXML

為{幸葍}努か 提交于 2020-01-02 03:57:05
问题 I'm working on a C#/ASP.NET web thing and want to do an Excel export. First I found OpenXML, made some first steps, but it's really hard to use. Now, I'm using ClosedXML and it's quite a relief - so far. I came up with the problem to have a gradient fill on a table cell ... no problem with normal fills like worksheet.Cell(1,1).Style.Fill.SetBackgroundColor(XLColor.Red); or with Patterns like worksheet.Cell(1,1).Style.Fill.PatternType = XLFillPatternValues.LightHorizontal; worksheet.Cell(1,1)

How to Read percentage value with sign(%) from Excel file using ClosedXml

房东的猫 提交于 2019-12-25 16:48:39
问题 Input: Cell Value=6.25%; var Value= ws1.Cell(rowNum, collNum).Value.ToString(); Output: 0.0625 Expected Output: 6.25% 回答1: I find the solution by using .GetFormattedString() insted of .Value 来源: https://stackoverflow.com/questions/44159232/how-to-read-percentage-value-with-sign-from-excel-file-using-closedxml

Creating pivot table using ClosedXML

孤街浪徒 提交于 2019-12-24 16:00:26
问题 I'm trying to create a Pivot table using ClosedXML V0.91.1, but I keep getting problems with my excel file having unreadable content and then the excel workbook removing my pivot table when clicking Yes below. Below is that shows when I hit Yes . It's removing my pivot table. My Pivot Table is getting data from a table that is created from a history of TFS Changesets. The changesets are set into a IEnumerable<Changeset> which is then converted into a DataTable object which include the column

issue with returning HttpResponseMessage as excel file in WebAPI

会有一股神秘感。 提交于 2019-12-24 07:52:19
问题 I have created WebAPI which returns an excel file using closedxml nuget. Basically it converts my DataTable to excel. I'm referring couple of links below, How to return a file (FileContentResult) in ASP.NET WebAPI Returning binary file from controller in ASP.NET Web API Issue : excel generated on server path has NO issues. But when I download the same by returning it as HttpResponseMessage via webAPI the excel file is corrupted. It says, "The file is corrupt and cannot be opened" :( My Code :

Remove all formatting of the table created from InsertTable method in ClosedXML

一笑奈何 提交于 2019-12-23 16:17:10
问题 I'm using ClosedXML to generate a report. The data supplied to Excel is from a database which is stored to a DataTable object. The table is displayed fine in the Excel sheet - however, it has a default theme applied on the created table. Below is my sample code: Dim workbook As XLWorkbook = New XLWorkbook() Dim _tempSummary= workbook.AddWorksheet("Summary").Cell(1, 1).InsertTable(tblSummary) This is the result: I wanted to remove the bold font styling of the created table. However, when I did

Set lock true for group of cells

℡╲_俬逩灬. 提交于 2019-12-23 07:57:36
问题 I'm using closedxml to export excel.. Now i can protect (Lock cell) cell using the following function, workSheet.Cell(rowIndex,column).Style.Protection.SetLocked(true); I want to set group of cells.. Is that Possible in closedxml ? 回答1: You can use Range like so workSheet.Range(startRow, startColumn, endRow, endColumn).Style.Protection.SetLocked(true); 回答2: @Raidri, thanks for the answer that you provided here, but I want to add my own answer. I found that when you want to lock a cell, the