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

Commented Unassigned: Array Formula crashes ClosedXml on Save [8934]

$
0
0
Hi there!

First, thank you for your hard work and ongoing support! After fiddling with OOXML myself "manually" for about a month and compiling numerous helper functions I really, really appreciate your effort ;-)

Now I've stumbled upon a rather complex array formula that works fine in Excel 2010 but throws a null reference exception on save() using ClosedXml.

In German this array formula looks like
```
=TEILERGEBNIS(9;INDIREKT("B02:B"&MAX(WENN(ISTLEER(#BEZUG!:B);"";ZEILE(B:B)))))
```
and results in
```
System.NullReferenceException: Object reference not set to an instance of an object.
at ClosedXML.Excel.XLWorkbook.GenerateWorksheetPartContent(WorksheetPart worksheetPart, XLWorksheet xlWorksheet, SaveContext context) in ...\ClosedXML\Excel\XLWorkbook_Save.cs:line 4096
at ClosedXML.Excel.XLWorkbook.CreateParts(SpreadsheetDocument document) in ...\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 189
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath) in ...\ClosedXML\Excel\XLWorkbook_Save.cs:line 91
at ClosedXML.Excel.XLWorkbook.Save() in ...\ClosedXML\Excel\XLWorkbook.cs:line 413
```
upon save().


Thanks for your help and best regards,
Thomas
Comments: ** Comment from web user: MDeLeon **

Thanks for the feedback. I'll think about your recommendations. Regarding the formula, I'll get Office 2010 and check it out because I seriously doubt that is a valid formula in Excel 2010 (or any other version for that matter).


New Comment on "How do I deliver an Excel file in ASP.NET?"

$
0
0
This probably isn't the "right" way to do it, but for the same result in an ASP.NET Web API, the following worked for me: public class WorkbookController : ApiController { public HttpResponseMessage Get() { // Create the workbook var workbook = new XLWorkbook(); workbook.Worksheets.Add("Sample").Cell(1, 1).SetValue("Hello World"); // Prepare the response HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); var memoryStream = new MemoryStream(); // If I put this in a 'using' construct, I never get the response back in a browser. workbook.SaveAs(memoryStream); memoryStream.Seek(0, SeekOrigin.Begin); // Seem to have to manually rewind stream before applying it to the content. response.Content = new StreamContent(memoryStream); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "HelloWorld.xlsx" }; return response; } }

New Post: Input string was not in a correct format when reading cell value

$
0
0
Has anyone found a work around for this?

New Post: Input string was not in a correct format when reading cell value

$
0
0
I'll work on it. It shouldn't be hard to fix... (famous last words I know)

New Post: Generate Excel and Add As Email Attachment

$
0
0
I had a similar problem. Solved with highlighted line of code before creating the attachment from memory stream.
using (MemoryStream memoryStream = new MemoryStream())
{
    MailMessage mailMessage = new MailMessage(smtpFrom, smtpTo);

    mailMessage.Subject = subject;
    mailMessage.Body = body;

    __memoryStream.Seek(0, SeekOrigin.Begin);__
    Attachment attachment = new Attachment(memoryStream, "<filename>.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    mailMessage.Attachments.Add(attachment);

    SmtpClient smtpClient = new SmtpClient(smtpServer);
    smtpClient.Send(mailMessage);

    memoryStream.Close();
}

New Post: Table Styles

$
0
0
There needs to be a none item in the enum. ActiveSheet.ListObjects("Table2").TableStyle = "" Is what is recorded when I record a macro.

Source code checked in, #79734

New Post: Table Styles

$
0
0
I didn't even know that was an option. Pick up the latest check-in.

Source code checked in, #79736

$
0
0
Formulas now treat strings as zero

New Post: Input string was not in a correct format when reading cell value

Commented Unassigned: Evaluating Formulas with Round() [8877]

$
0
0
Hi,

ClosedXML doesn't evaluate formulas with the Round() function.

PS: Is their a list of supported / not supported functions?

Greetings,
Raidri
Comments: ** Comment from web user: MDeLeon **

The Round function works just fine:

var wb = new XLWorkbook();
var ws = wb.AddWorksheet("Sheet1");
var value = ws.FirstCell().SetFormulaA1("=ROUND(1.239, 2)").GetDouble();

From the downloads page: (I'll add it to the documentation)

This is a list of the included formulas:

All math and trigonometric formulas.
All text formulas except BAHTTEXT, JIS, and PHONETIC.
All logical formulas.
All date and time formulas.
Many statistical formulas.

Closed Unassigned: Evaluating Formulas with Round() [8877]

$
0
0
Hi,

ClosedXML doesn't evaluate formulas with the Round() function.

PS: Is their a list of supported / not supported functions?

Greetings,
Raidri
Comments: Nothing to do.

New Post: Table Styles

Commented Unassigned: Array Formula crashes ClosedXml on Save [8934]

$
0
0
Hi there!

First, thank you for your hard work and ongoing support! After fiddling with OOXML myself "manually" for about a month and compiling numerous helper functions I really, really appreciate your effort ;-)

Now I've stumbled upon a rather complex array formula that works fine in Excel 2010 but throws a null reference exception on save() using ClosedXml.

In German this array formula looks like
```
=TEILERGEBNIS(9;INDIREKT("B02:B"&MAX(WENN(ISTLEER(#BEZUG!:B);"";ZEILE(B:B)))))
```
and results in
```
System.NullReferenceException: Object reference not set to an instance of an object.
at ClosedXML.Excel.XLWorkbook.GenerateWorksheetPartContent(WorksheetPart worksheetPart, XLWorksheet xlWorksheet, SaveContext context) in ...\ClosedXML\Excel\XLWorkbook_Save.cs:line 4096
at ClosedXML.Excel.XLWorkbook.CreateParts(SpreadsheetDocument document) in ...\ClosedXML\ClosedXML\Excel\XLWorkbook_Save.cs:line 189
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath) in ...\ClosedXML\Excel\XLWorkbook_Save.cs:line 91
at ClosedXML.Excel.XLWorkbook.Save() in ...\ClosedXML\Excel\XLWorkbook.cs:line 413
```
upon save().


Thanks for your help and best regards,
Thomas
Comments: ** Comment from web user: MDeLeon **

I took a second look and the formula does work even in Excel 2007. I'll see what I can do...

New Post: NamedRanges.Contains pick other NamedRange if one doesnt exist

$
0
0
Thanks MDeLeon but the codes you've provided are still throwing following exceptions

var range1 = ws.NamedRange("Bad");
ex = {"The given key was not present in the dictionary."}

var contains1 = ws.NamedRanges.Contains("Bad");
ex = {"Index was outside the bounds of the array."}

At the moment I've done a work around by getting all NamedRanges in a string collection then doing a Contains

New Post: NamedRanges.Contains pick other NamedRange if one doesnt exist

$
0
0
You have to get the source code and compile it.

New Post: IXCell.DataType isn't set DateTime type when the cell contains VLOOKUP formula

$
0
0
Into a worksheet, a column has VLOOKUP formula to obtain a date from another sheet in the same workbook. But when checking the IXCell.DataType property, I get the Text data type instead of Date data type.

Thanks in advanced

New Post: IXCell.DataType isn't set DateTime type when the cell contains VLOOKUP formula

$
0
0
It could simply be that Excel has the cell type as text even though the lookup value is a date. Create an issue and attach the file.

New Post: IXCell.DataType isn't set DateTime type when the cell contains VLOOKUP formula

$
0
0
MDeLeon,

Thanks for your response.

I've checked the Cell Format and it has defined as Date. I'll be creating an issue with a sample file.

New Post: IXCell.DataType isn't set DateTime type when the cell contains VLOOKUP formula

$
0
0
MDeLeon,

Thanks for your response.

I've checked the Cell Format and it has defined as Date. I'll be creating an issue with a sample file.
Viewing all 1877 articles
Browse latest View live


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