Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all 1877 articles
Browse latest View live

Commented Unassigned: System.OutOfMemoryException in v0.68.0.10, regression? [8808]

$
0
0
Hello,

In order to improve the speed of reading/writing of Excel files, I have recently updated ClosedXML from v0.64.0.0 to v0.68.0.10.

The kind of Excel file that I deal with is a big file, embedding a lot of VBA code ; I use it as a template, filling only 2 sheets with raw data (number or string, no formula).

The VBA developper improve this file continuously, for some files there was a huge speed difference, but we have arrived in a point where :

- With v0.64.0.0, we have the good results, but it is very slow
- With v0.68.0.10, the memory is increasing and then a "System.OutOfMemoryException" is thrown.

The exception is thrown in the code below

```
public XLWorkbook OpenExcel(MemoryStream xlsStream)
{
return new XLWorkbook(xlsStream, XLEventTracking.Disabled); //RR 13/06/2013 Turning off events
}
```

with v0.64.0.0 the memory is not increasing a lot during this operation (quite stable), but with v0.68.0.10 the memory used is increasing a lot (1 more GB) and then the exception occured.

I try to turn of the events, but it doesn't change anything.

Does anyone else had this issue before?

Thank you very much for your help.

Regards,
Renaud
Comments: ** Comment from web user: RenaudR **

I don't know if the situation has changed with the last version (0.69)


Commented Unassigned: System.OutOfMemoryException in v0.68.0.10, regression? [8808]

$
0
0
Hello,

In order to improve the speed of reading/writing of Excel files, I have recently updated ClosedXML from v0.64.0.0 to v0.68.0.10.

The kind of Excel file that I deal with is a big file, embedding a lot of VBA code ; I use it as a template, filling only 2 sheets with raw data (number or string, no formula).

The VBA developper improve this file continuously, for some files there was a huge speed difference, but we have arrived in a point where :

- With v0.64.0.0, we have the good results, but it is very slow
- With v0.68.0.10, the memory is increasing and then a "System.OutOfMemoryException" is thrown.

The exception is thrown in the code below

```
public XLWorkbook OpenExcel(MemoryStream xlsStream)
{
return new XLWorkbook(xlsStream, XLEventTracking.Disabled); //RR 13/06/2013 Turning off events
}
```

with v0.64.0.0 the memory is not increasing a lot during this operation (quite stable), but with v0.68.0.10 the memory used is increasing a lot (1 more GB) and then the exception occured.

I try to turn of the events, but it doesn't change anything.

Does anyone else had this issue before?

Thank you very much for your help.

Regards,
Renaud
Comments: ** Comment from web user: MDeLeon **

Can anyone prepare a project that reproduces the behavior? I'll then profile it and tune the library where appropriate. Thanks.

Commented Unassigned: System.OutOfMemoryException in v0.68.0.10, regression? [8808]

$
0
0
Hello,

In order to improve the speed of reading/writing of Excel files, I have recently updated ClosedXML from v0.64.0.0 to v0.68.0.10.

The kind of Excel file that I deal with is a big file, embedding a lot of VBA code ; I use it as a template, filling only 2 sheets with raw data (number or string, no formula).

The VBA developper improve this file continuously, for some files there was a huge speed difference, but we have arrived in a point where :

- With v0.64.0.0, we have the good results, but it is very slow
- With v0.68.0.10, the memory is increasing and then a "System.OutOfMemoryException" is thrown.

The exception is thrown in the code below

```
public XLWorkbook OpenExcel(MemoryStream xlsStream)
{
return new XLWorkbook(xlsStream, XLEventTracking.Disabled); //RR 13/06/2013 Turning off events
}
```

with v0.64.0.0 the memory is not increasing a lot during this operation (quite stable), but with v0.68.0.10 the memory used is increasing a lot (1 more GB) and then the exception occured.

I try to turn of the events, but it doesn't change anything.

Does anyone else had this issue before?

Thank you very much for your help.

Regards,
Renaud
Comments: ** Comment from web user: RenaudR **

Unfortunatly, I'm not allowed to provide the data that reproduces the behavior :(

Commented Unassigned: System.OutOfMemoryException in v0.68.0.10, regression? [8808]

$
0
0
Hello,

In order to improve the speed of reading/writing of Excel files, I have recently updated ClosedXML from v0.64.0.0 to v0.68.0.10.

The kind of Excel file that I deal with is a big file, embedding a lot of VBA code ; I use it as a template, filling only 2 sheets with raw data (number or string, no formula).

The VBA developper improve this file continuously, for some files there was a huge speed difference, but we have arrived in a point where :

- With v0.64.0.0, we have the good results, but it is very slow
- With v0.68.0.10, the memory is increasing and then a "System.OutOfMemoryException" is thrown.

The exception is thrown in the code below

```
public XLWorkbook OpenExcel(MemoryStream xlsStream)
{
return new XLWorkbook(xlsStream, XLEventTracking.Disabled); //RR 13/06/2013 Turning off events
}
```

with v0.64.0.0 the memory is not increasing a lot during this operation (quite stable), but with v0.68.0.10 the memory used is increasing a lot (1 more GB) and then the exception occured.

I try to turn of the events, but it doesn't change anything.

Does anyone else had this issue before?

Thank you very much for your help.

Regards,
Renaud
Comments: ** Comment from web user: MDeLeon **

I don't mean for you to give me your data. Just make a loop and create worksheets/rows with dummy values and formatting that kind of resembles what you have.

New Post: Exception when creating or loading workbook: When using relative paths, make sure the current directory is correct.

$
0
0
I'm getting an exception with only a single line of code;
    static void Main(string[] args)
    {
        XLWorkbook workbook = new XLWorkbook(); 
    }
"The type initializer for 'ClosedXML.Excel.XLWorkbook' threw an exception."
"InnerException: When using relative paths, make sure the current directory is correct."

This must be a configuration error? I've added "ClosedXML" and "DocumentFormat.OpenXml" to References. I also get this exception trying to load a workbook.

It has been a frustrating day of Koogra, NPOI, OpenXML! They all seem to have their quirks. All I really want to do is dump the cell contents of every named range in a workbook. With OpenXML I couldn't get it to write dates properly and cycling through each cell in the range was quirky. I've tried multiple StackOverlfow examples.

I Googled the exact text of the exception & it doesn't appear anywhere.

Thanks in advance for any ideas.

Commented Unassigned: German Special Characters Problem when Exporting to Excel [8869]

$
0
0
Hello,

i`m sucessfully exporting a GridView into Excel but when using german special characters (ä, ü, ö, ß) they get replaced with "& #252;" in the excel file. Is there a way to fix that problem? Not using these characters isn't an option. ;-)

My Code looks like following:

```
protected void Button1_Click(object sender, EventArgs e)
{
// Create the workbook
var Workbook = new XLWorkbook();

// Create the table
DataTable dt = new DataTable();

// Important because the sheet must have a name
dt.TableName = "Information";

// Not allowing Paging to avoid potential problems with GridView
// Replaces gvUpLoad with your own GridView
GridView1.AllowPaging = false;

// Loop the GridView to copy it as DataTable
// add the columns to the datatable
if (GridView1.HeaderRow != null)
{
for (int i = 0; i < GridView1.HeaderRow.Cells.Count; i++)
{
dt.Columns.Add(GridView1.HeaderRow.Cells[i].Text);
}
}

// add each of the data rows to the table
foreach (GridViewRow row in GridView1.Rows)
{
DataRow dr;
dr = dt.NewRow();

for (int i = 0; i < row.Cells.Count; i++)
{
dr[i] = row.Cells[i].Text.Replace(" ", "");
}
dt.Rows.Add(dr);
}

// add the footer row to the table
if (GridView1.FooterRow != null)
{
DataRow dr;
dr = dt.NewRow();

for (int i = 0; i < GridView1.FooterRow.Cells.Count; i++)
{
dr[i] = GridView1.FooterRow.Cells[i].Text.Replace(" ", "");
}
dt.Rows.Add(dr);
}

// Add a DataTable as a worksheet
Workbook.Worksheets.Add(dt);

// Create Response
HttpResponse response = Response;

//Prepare the response
response.Clear();
response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
response.AddHeader("content-disposition", "attachment;filename=HelloWorld.xlsx");

//Flush the workbook to the Response.OutputStream
using (MemoryStream MyMemoryStream = new MemoryStream())
{
Workbook.SaveAs(MyMemoryStream);
MyMemoryStream.WriteTo(response.OutputStream);
MyMemoryStream.Close();
}

response.End();
```

Thanks in Advance for any help.

Greetings

musti2k3
Comments: ** Comment from web user: losmoz **

Hi musti2k3,

When you assign the content of a GridView cell to a DataTable cell, the content is Html-encoded. What you need to do is decode the content before you assign it. You can modify your code this way:

```
// add each of the data rows to the table
foreach (GridViewRow row in GridView1.Rows)
{
DataRow dr;
dr = dt.NewRow();

for (int i = 0; i < row.Cells.Count; i++)
{
dr[i] = __System.Net.WebUtility.HtmlDecode(__row.Cells[i].Text__)__;
}
dt.Rows.Add(dr);
}

```

Hope this helps... :)

New Post: Exception when creating or loading workbook: When using relative paths, make sure the current directory is correct.

$
0
0
I was finally able to display dates out of OpenXML, which reminds me-- I'm amazed that you have written your ClosedXML library with so much functionality given the documentation and the difficulty of simple operations in OpenXML! It seems to me that most of the examples for OpenXML involve creating worksheets, not extracting data from them.

New Post: Exception when creating or loading workbook: When using relative paths, make sure the current directory is correct.

$
0
0
It takes a LOT of patience.

Do this: Create a new project, add the references to ClosedXML and DocumentFormat.OpenXml, put "var wb = new XLWorkbook();" on Main. If you still get the error then create an issue and attach the project so I can see the error for myself.

Manuel

New Post: Insert cell, rather than column

$
0
0
Is it possible to make a new feature that allow for a cell to be inserted at a specific location, rather than having to insert a whole column or row?

If this feature does already exist, please point in the direction of some documentation or code snippets.

Thanks in advance.
Best regards
Teambit

New Post: Unable to use Save / SaveAs TypeLoadException

$
0
0
Hi,

Many thanks for all your great work on this but I seem to have come up with an issue when saving a file. I get the following error:

Could not load type 'DocumentFormat.OpenXml.Spreadsheet.SmartTags' from assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Code is as follows:
        var wb = new XLWorkbook(filename);
        var ws = wb.Worksheet("All DATA");
        ws.Cell("BH4").Value = "Result";
        ws.Cell("BI4").Value = "Validations";

        wb.SaveAs(filename);
Excel file was written in Excel2010

Im using:
.NET Framework 4.5
ClosedXml 0.69.1.0
DocumentFormat.OpenXml 2.5.5631.0

Please could you assist me and point me in the best direction?

Many thanks

Tish

New Post: Insert cell, rather than column

$
0
0
cell.InsertCellsAbove
cell.InsertCellsBelow
cell.InsertCellsAfter
cell.InsertCellsBefore

New Post: Unable to use Save / SaveAs TypeLoadException

$
0
0
Use DocumentFormat.OpenXml 2.0

Are you using Nuget? If so, it could be that my package is not configured correctly and it's picking up the latest DocumentFormat dll instead of the 2.0 one.

Thanks,

Updated Wiki: Home

$
0
0

Project Description

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).

Q: Dude, where have you been?

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.

Q: Why a survey tool?

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 ^_^


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:

Showcase.jpg

 

Updated Wiki: Home

$
0
0

Project Description

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).

Q: Dude, where have you been?

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.

Q: Why a survey tool?

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 ^_^


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:

Showcase.jpg

 

New Post: Unable to use Save / SaveAs TypeLoadException

$
0
0
Thanks for that. I've figured it out and it was due to pulling down a later version of OpenXml from Nuget and then pulling down ClosedXml which caused the confusion in the solution so you were spot on. Many thanks for getting back to me :)

New Post: Insert cell, rather than column

$
0
0
Right. Thanks MDeLeon. This is a great piece of software. It saves me a lot of manhours.

Best regards
Teambit

Reviewed: ClosedXML 0.69.1 (Sep 05, 2013)

$
0
0
Rated 4 Stars (out of 5) - I think it's very convinent in generating excel

Commented Unassigned: Open XML 2.5 [8873]

$
0
0
Hi,

if i use Open XML 2.5 the ClosedXML library not work because, i thing, is compiled with Open XML 2.0.
It 'will be a new implementation of ClosedXML with Open XML 2.5 version?

Thanks
Comments: ** Comment from web user: the_ravent **

The same problem
> System.TypeInitializationException : The type initializer for 'ClosedXML.Excel.XLWorkbook' threw an exception.
----> System.IO.FileLoadException : Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

But latest version of OpenXML that is available on NuGet is 2.5.5631.0

Closed Unassigned: Open XML 2.5 [8873]

$
0
0
Hi,

if i use Open XML 2.5 the ClosedXML library not work because, i thing, is compiled with Open XML 2.0.
It 'will be a new implementation of ClosedXML with Open XML 2.5 version?

Thanks
Comments: The OpenXML SDK 2.5 only works with .Net 4.0
More importantly, it doesn't add anything to the table so there's no reason to bother using it anyway. The only thing it will accomplish is to prevent ClosedXML from being used in .NET 3.5 projects.

New Post: Adding OLEObjects to the worksheet

$
0
0
Is there any API to insert an OLEObject (Word document) into the Excel Worksheet? I need this feature for a business application and it would be great to get rid of the native API (very slow)
The equivalent interop API is Sheet.Shapes.AddOLEObject.
Viewing all 1877 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>