Thanks, Simona
Thanks, Simona
This is a huge issue for me. This single issue is preventing me from going live on Azure.
ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).
A: I've been making a survey app called Conspek. It's now open to the public. My hope is that it will be able to pay the bills and allow me to keep working on ClosedXML.
A: The same reason I created ClosedXML, I wasn't happy with my options. A while back I had to create a survey but all online survey apps were fiendishly hard, all so clunky, and with a million options in my face (that I would never use). So I created my own survey tool with the goal of making the experience as easy and simple as possible. Try it out and give me some feedback at Conspek.com ^_^
What can you do with this?
ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.
If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.
var workbook = new XLWorkbook(); var worksheet = workbook.Worksheets.Add("Sample Sheet"); worksheet.Cell("A1").Value = "Hello World!"; workbook.SaveAs("HelloWorld.xlsx");
Something more elaborate:
The Documentation page has an example of how to create the following table (Showcase) as well as many other examples:
destBook.NamedRanges.Add(namedRange.Name, range);
} for (int i = 1; i < subscriptionsByPages.Count(); i++) {
ws.Cell("A" + (i * verticalPageSize + 1)).Value = ws.Range("A1:AB45");
}
This code take about 95% of time and take about 5 minutes for 35-40 print page (1600-1800 rows on the sheet). I profile code and my result is:Thanks for this useful project.
A question about this. So, how I can test if cell is formatted as date?
Thanks in advance,
Alfonso
Don't save the workbook to a MemoryStream because this - as the name suggests - loads the entire thing into memory, which is one of the things causing your OutOfMemoryException.
I suggest saving it to a temporary file on the file system then use Response.TransmitFile to send it. You will need to have some housekeeping task to tidy up the temporary files.
using (XLWorkbook workbook = new XLWorkbook(@"template.xlsx"))
{
// Access sheet and table by indices because this example only contains one sheet and one table.
IXLWorksheet sheet = workbook.Worksheet(1);
IXLTable table = sheet.Table(0);
workbook.SaveAs(@"resultOriginal.xlsx");
// Change first column header text.
table.Cell(1, 1).Value = "Name";
workbook.SaveAs(@"result.xlsx");
}