closedxml

Sort a table in ClosedXML while keeping header row

给你一囗甜甜゛ 提交于 2019-12-11 06:09:56
问题 I've tried a few methods of sorting in ClosedXML but they've all had the same results: the first row of data becomes the new header in excel. Here's the code I've used so far: Dim dtChangedScores As New DataTable dtChangedScores.Columns.Add("Name") dtChangedScores.Columns.Add("Old Score") dtChangedScores.Columns.Add("New Score") Dim dr As DataRow = dtChangedScores.NewRow dr("Name") = "aaa" dr("Old Score") = "bbb" dr("New Score") = "bbb" dtChangedScores.Rows.Add(dr) 'etc.... Dim wb = New

Create dropdown list using ClosedXML

杀马特。学长 韩版系。学妹 提交于 2019-12-10 18:52:37
问题 I have implemented Excel template download in my project. I used ClosedXML . I have two excel sheets Sheet1: In this sheet, I have a column called " Type " in which I can create Dropdown List and it is the third column. Sheet 2: In this sheet, I have a column called " Types " and its Range Address is: "B2:B4" and it is the second column. Types values are: Employee Student Teacher Now, I want to create a dropdown list. I created a dropdownlist in ClosedXML and the code is: //Getting the range

How to get the full value from an excel cell, not the displayed (rounded) value?

旧时模样 提交于 2019-12-10 18:39:39
问题 I'm having an issue retrieving the exact value from an cell from a worksheet. If I open the file the cell has a decimal number which it's shown only with 4 decimals, but if I click on the particular cell, the value is different, having 6 decimals. I know it's a setting applied to the cell in order to show only 4 decimals. Now I'm trying to retrieve the cell's data in C#, using ClosedXML.Excel, not Microsoft.Office.Interop.Excel, but the only thing I'm able to get is the 4 decimals value, not

How to assign a list to a Cell(Dropdown format) in closedXML while Exporting to Excel

我只是一个虾纸丫 提交于 2019-12-10 18:18:53
问题 I am just trying to Export a Datatable ( Datatable doesn't have any data - having only header). In addition, i have a List<String> which i want to append to the column, such that, after export to excel that column (all cells except header) should contain list data as Dropdown format. I have googled a lot and couldn't able to find any solutions. Below are the links which i have visited but no luck. StackOverflow Codeplex - ClosedXML And below are the one what i have tried so far. private void

Is OpenXML SDK required to be installed in every computer that will run my program?

梦想的初衷 提交于 2019-12-10 10:54:15
问题 Is there a way to deploy my application (which uses ClosedXML) and not be required to install OpenXMLSDKv2.msi on each computer? If I uninstall the sdk I get this error at runtime: I already referenced DocumentFormat.OpenXml (copy local = true) and WindowsBase (also copy local true, despite being not necessary. DocumentFormat.OpenXml.dll and ClosedXML.dll are both on the bin folder. 回答1: DocumentFormat.OpenXml.dll and ClosedXML.dll are both on the bin folder. This should be enough, no

Append to excel file with ClosedXML

你。 提交于 2019-12-09 05:28:04
问题 I need to append new data to existing excel file created with ClosedXML. How can I append to an excel file using ClosedXML? How can I get the row number of the last record and append to that or is there something other? Thanks! 回答1: Open the existing workbook and then use the Last*Used methods: XLWorkbook Workbook = new XLWorkbook(@"C:\existing_excel_file.xlsx"); IXLWorksheet Worksheet = Workbook.Worksheet("Name or index of the sheet to use"); int NumberOfLastRow = Worksheet.LastRowUsed()

Can I save an EXCEL worksheet as CSV via ClosedXML?

杀马特。学长 韩版系。学妹 提交于 2019-12-08 16:29:22
问题 Is it possible to save a worksheet of a workbook as CSV via ClosedXML? For example: var workbook = new XLWorkbook(fileName); IXLWorksheet worksheet; workbook.Worksheets.TryGetWorksheet(sheetName, out worksheet); worksheet. /How to Save it as CSV? 回答1: No, it is not possible directly in ClosedXML. You have to use loops or LINQ to build your own CSV file. For example: System.IO.File.WriteAllLines(csvFileName, worksheet.RowsUsed().Select(row => string.Join(";", row.Cells(1, row.LastCellUsed

“Cannot convert theme color to Color” in ClosedXml

我怕爱的太早我们不能终老 提交于 2019-12-08 11:27:32
问题 I am trying to read the fill background colour of cells in Excel using ClosedXml. I am working from this sample code and have been able to read the content of a Excel document without issues, but am not able to read the Fill BackgroundColor for the cell as a hexadecimal value. I am able to see the ThemeColor and ThemeTint properties defined under BackgroundColor but have not found a way to convert these into either System.Color or a hex value. Here is my code: // Get all categories while (

Is OpenXML SDK required to be installed in every computer that will run my program?

﹥>﹥吖頭↗ 提交于 2019-12-06 04:15:27
Is there a way to deploy my application (which uses ClosedXML) and not be required to install OpenXMLSDKv2.msi on each computer? If I uninstall the sdk I get this error at runtime: I already referenced DocumentFormat.OpenXml (copy local = true) and WindowsBase (also copy local true, despite being not necessary. DocumentFormat.OpenXml.dll and ClosedXML.dll are both on the bin folder. Raidri says Reinstate Monica DocumentFormat.OpenXml.dll and ClosedXML.dll are both on the bin folder. This should be enough, no installation required. See this question for other takes on this error (for all dlls,

ClosedXML add image

早过忘川 提交于 2019-12-05 20:02:24
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.WorksheetParts.First().AddNewPart<DrawingsPart>(); ImagePart imgp = dp.AddImagePart(ImagePartType.Jpeg, sd