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

Closed Unassigned: System.ApplicationException: Column Length must be between 1 and 3. [9206]

$
0
0
When I run this code (there is Data column in my sheet)
```
Console.WriteLine(ws.Cell(2, "Data").GetString());

```

I get this exception
```
Unhandled Exception: System.ApplicationException: Column Length must be between 1 and 3.
at ClosedXML.Excel.XLHelper.GetColumnNumberFromLetter(String columnLetter)
at ClosedXML.Excel.XLAddress..ctor(XLWorksheet worksheet, Int32 rowNumber, String columnLetter, Boolean fixedRow, Boolean fixedColumn)
at ClosedXML.Excel.XLWorksheet.ClosedXML.Excel.IXLWorksheet.Cell(Int32 row, String column)
at ObslugaExcela.Program.Main(String[] args) in e:\DATA\CS-solutions\Polkomtel\ObslugaExcela\ObslugaExcela\Program.cs:line 29

```

I am using .Net 3.5 and ClosedXML 0.69.1.0
Comments: Not a real issue. Closed.

Edited Unassigned: System.ApplicationException: Column Length must be between 1 and 3. [9206]

$
0
0
When I run this code (there is Data column in my sheet)
```
Console.WriteLine(ws.Cell(2, "Data").GetString());

```

I get this exception
```
Unhandled Exception: System.ApplicationException: Column Length must be between 1 and 3.
at ClosedXML.Excel.XLHelper.GetColumnNumberFromLetter(String columnLetter)
at ClosedXML.Excel.XLAddress..ctor(XLWorksheet worksheet, Int32 rowNumber, String columnLetter, Boolean fixedRow, Boolean fixedColumn)
at ClosedXML.Excel.XLWorksheet.ClosedXML.Excel.IXLWorksheet.Cell(Int32 row, String column)
at ObslugaExcela.Program.Main(String[] args) in e:\DATA\CS-solutions\Polkomtel\ObslugaExcela\ObslugaExcela\Program.cs:line 29

```

I am using .Net 3.5 and ClosedXML 0.69.1.0

Created Issue: XLHelper is not thread safe [9355]

$
0
0
This was reported as a comment in this issue

https://closedxml.codeplex.com/workitem/9348

Commented Issue: XLHelper is not thread safe [9355]

$
0
0
This was reported as a comment in this issue

https://closedxml.codeplex.com/workitem/9348
Comments: Pull request opened https://closedxml.codeplex.com/SourceControl/network/forks/NickNack2020/ClosedXml/contribution/7226

Commented Unassigned: Multithreading- AdjustToContents not threadsafe [9348]

$
0
0
Hi,

I have recently upgraded from 0.65 to 0.73 and while I have seen some performance improvements, several reports that run in parallel threads crashed in my UAT environment. It seems the problem is in the AdjustToContents() method.

The full exception is:

---> System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
at System.Drawing.Graphics.MeasureString(String text, Font font, Int32 width, StringFormat format)
at ClosedXML.Excel.FontBaseExtensions.GetWidth(IXLFontBase fontBase, String text, Dictionary`2 fontCache)
at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow, Double minWidth, Double maxWidth)
at ClosedXML.Excel.XLColumns.<AdjustToContents>b__8(XLColumn c)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at ClosedXML.Excel.XLColumns.AdjustToContents()



Comments: Issue opened for XLHelper https://closedxml.codeplex.com/workitem/9355

Commented Unassigned: Multithreading- AdjustToContents not threadsafe [9348]

$
0
0
Hi,

I have recently upgraded from 0.65 to 0.73 and while I have seen some performance improvements, several reports that run in parallel threads crashed in my UAT environment. It seems the problem is in the AdjustToContents() method.

The full exception is:

---> System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
at System.Drawing.Graphics.MeasureString(String text, Font font, Int32 width, StringFormat format)
at ClosedXML.Excel.FontBaseExtensions.GetWidth(IXLFontBase fontBase, String text, Dictionary`2 fontCache)
at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow, Double minWidth, Double maxWidth)
at ClosedXML.Excel.XLColumns.<AdjustToContents>b__8(XLColumn c)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at ClosedXML.Excel.XLColumns.AdjustToContents()



Comments: Issue for IntergerExtensions.ToStringLookup https://closedxml.codeplex.com/workitem/9118

Edited Unassigned: Multithreading- AdjustToContents not threadsafe [9348]

$
0
0
Hi,

I have recently upgraded from 0.65 to 0.73 and while I have seen some performance improvements, several reports that run in parallel threads crashed in my UAT environment. It seems the problem is in the AdjustToContents() method.

The full exception is:

---> System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
at System.Drawing.Graphics.MeasureString(String text, Font font, Int32 width, StringFormat format)
at ClosedXML.Excel.FontBaseExtensions.GetWidth(IXLFontBase fontBase, String text, Dictionary`2 fontCache)
at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow, Double minWidth, Double maxWidth)
at ClosedXML.Excel.XLColumns.<AdjustToContents>b__8(XLColumn c)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at ClosedXML.Excel.XLColumns.AdjustToContents()



Commented Unassigned: Multithreading- AdjustToContents not threadsafe [9348]

$
0
0
Hi,

I have recently upgraded from 0.65 to 0.73 and while I have seen some performance improvements, several reports that run in parallel threads crashed in my UAT environment. It seems the problem is in the AdjustToContents() method.

The full exception is:

---> System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
at System.Drawing.Graphics.MeasureString(String text, Font font, Int32 width, StringFormat format)
at ClosedXML.Excel.FontBaseExtensions.GetWidth(IXLFontBase fontBase, String text, Dictionary`2 fontCache)
at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow, Double minWidth, Double maxWidth)
at ClosedXML.Excel.XLColumns.<AdjustToContents>b__8(XLColumn c)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at ClosedXML.Excel.XLColumns.AdjustToContents()



Comments: Alright, that is it for me tonight. Here is the pull request to make AdjustToContents thread safe https://closedxml.codeplex.com/SourceControl/network/forks/NickNack2020/ClosedXml/contribution/7227 I will continue to look into Tornhoof's list when I get a chance if no one else does. Thank you very much for the list.

Commented Issue: "Unreadable content" when editing and reopening generated file in Excel 2010 [8466]

$
0
0
The problem is described in the discussions in the following thread: http://closedxml.codeplex.com/discussions/403797
When I open an existing Excel file using ClosedXml and save it (even without performing any actions), the file gets corrupted when it is edited using Excel 2010 afterwards. Excel 2007 and Excel 2013 do not produce the problem on my Systems (tested with WinXP and Win8).
I've attached the following small sample program:

```
namespace ClosedXml_Template_Test
{
using System.IO;
using ClosedXML.Excel;
class Program
{
static void Main(string[] args)
{
string inFilepath = "Template.xlsx";
string outFilepath = "Generated.xlsx";
byte[] fileContent;
using (FileStream fileStream = File.OpenRead(inFilepath))
{
// Read from file
fileContent = new byte[fileStream.Length];
fileStream.Read(fileContent, 0, fileContent.Length);
}
using (MemoryStream memStream = new MemoryStream())
{
// Write to MemoryStream
memStream.Write(fileContent, 0, fileContent.Length);
// Create ClosedXml instances
using (XLWorkbook workbook = new XLWorkbook(memStream, XLEventTracking.Disabled))
{
// Save the workbook to the stream
workbook.Save();
}
// Get the content from the stream
fileContent = memStream.ToArray();
}
if (File.Exists(outFilepath))
{
// Delete existing generated file
File.Delete(outFilepath);
}
using (FileStream fileStream = File.OpenWrite(outFilepath))
{
// Save the new file
fileStream.Write(fileContent, 0, fileContent.Length);
}
}
}
}
```

EDIT: Reformatted the post (CodePlex somehow killed the layout...)
Comments: I would like to look into this, but I am unable to reproduce the issue on my machine. Can you tell me what versions off Excel/Office you are using, and if the issue still happens for you.

Closed Issue: Excel file opening fail if there is no WorkbookProperties defined [8537]

$
0
0
If a excel File has no WorkbookProperties defined the document load fails.

ClosedXML.Excel.XLWorkbook_Load.cs

var date1904 = dSpreadsheet.WorkbookPart.Workbook.WorkbookProperties.Date1904;

It raise "Object reference not set to an instance of an object"

Edited Issue: XLColor is not threadsafe [9354]

$
0
0
As reported in issue https://closedxml.codeplex.com/workitem/9348 XLColor is not thread safe.

I was able to reproduce this issue.

Commented Unassigned: Bug if worksheet name contains ' character [9220]

$
0
0
If a a worksheet name contains one or more apostroph characters (') and if a print area is defined for that worksheet, then __new XLWorkbook("mybook.xlsx")__ fails.

The problem is in XLWorkbook_Load.cs

```
private static void ParseReference(string item, out string sheetName, out string sheetArea)
{
var sections = item.Trim().Split('!');

// If the worksheet name is "D'Artagnan" (encoded as 'D''Artagnan')
// *all* apostrophs will get stripped and we get "DArtagnan" instead of "D'Artagnan"
sheetName = sections[0].Replace("\'", "");
sheetArea = sections[1];
}
```

This will lead to an exception later in the XLWorksheets.Worksheet method.

The attached xlsx file exposes the bug.
Comments: The proposed fix causes corrupt output with Excel 2010 on my machine.

Edited Issue: System.InvalidOperationException: Sequence contains no elements [9022]

$
0
0
Getting the following exception when reading/evaluation a cell value that contains "=MAX(V7, W7) * 8%" formula:

An Exception occurred: System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Max(IEnumerable`1 source)
at ClosedXML.Excel.CalcEngine.Tally.Max()
at ClosedXML.Excel.CalcEngine.Statistical.Max(List`1 p)
at ClosedXML.Excel.CalcEngine.FunctionExpression.Evaluate()
at ClosedXML.Excel.CalcEngine.Expression.op_Implicit(Expression x)
at ClosedXML.Excel.CalcEngine.BinaryExpression.Evaluate()
at ClosedXML.Excel.CalcEngine.Expression.op_Implicit(Expression x)
at ClosedXML.Excel.CalcEngine.BinaryExpression.Evaluate()
at ClosedXML.Excel.CalcEngine.CalcEngine.Evaluate(String expression)
at ClosedXML.Excel.XLWorksheet.Evaluate(String expression)
at ClosedXML.Excel.XLCell.get_Value()

Both V7 and W7 cell values are blank, but excel handles this scenario by evaluating MAX to 0.0.

Commented Issue: System.InvalidOperationException: Sequence contains no elements [9022]

$
0
0
Getting the following exception when reading/evaluation a cell value that contains "=MAX(V7, W7) * 8%" formula:

An Exception occurred: System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Max(IEnumerable`1 source)
at ClosedXML.Excel.CalcEngine.Tally.Max()
at ClosedXML.Excel.CalcEngine.Statistical.Max(List`1 p)
at ClosedXML.Excel.CalcEngine.FunctionExpression.Evaluate()
at ClosedXML.Excel.CalcEngine.Expression.op_Implicit(Expression x)
at ClosedXML.Excel.CalcEngine.BinaryExpression.Evaluate()
at ClosedXML.Excel.CalcEngine.Expression.op_Implicit(Expression x)
at ClosedXML.Excel.CalcEngine.BinaryExpression.Evaluate()
at ClosedXML.Excel.CalcEngine.CalcEngine.Evaluate(String expression)
at ClosedXML.Excel.XLWorksheet.Evaluate(String expression)
at ClosedXML.Excel.XLCell.get_Value()

Both V7 and W7 cell values are blank, but excel handles this scenario by evaluating MAX to 0.0.
Comments: Pull request opened https://closedxml.codeplex.com/SourceControl/network/forks/NickNack2020/ClosedXml/contribution/7236

New Post: Protect Workbook

$
0
0
Excellent, thanks for that. Are there any plans for a new release (i.e. 0.74)?

And how about password protected workbook protection, is it being worked on, or are there no current plans to do so?

Thanks again!

Reviewed: ClosedXML 0.73.0 (Aug 04, 2014)

$
0
0
Rated 5 Stars (out of 5) - Excellent, only had infrequent problems, and all eventually solved as being (mostly) due to my own issue(s)!

Created Unassigned: Getting the Value for a Date Throws System.Format Exception [9356]

Commented Unassigned: Getting the Value for a Date Throws System.Format Exception [9356]

$
0
0
Getting the Value for a Date
Comments: If the Following Code Contains a Date in Cell A2, I Get a System.FormatException -- same as the time Code: XLWorkbook rdsWorkbook = new XLWorkbook(rdsFile); var p = rdsWorkbook.Worksheet("Sheet1").Range("A2").FirstCell(); Immediate Window: Hyperlink: {ClosedXML.Excel.XLHyperlink} NewDataValidation: {ClosedXML.Excel.XLDataValidation} RichText: {1/1/2013} ShareString: true Style: {Font:False-False-Single-False-Baseline-False-11-Color Theme: Text1, Tint: 1-Calibri-Swiss Fill:Color Index: 64-None-Color Index: 64 Border:None-FF000000-None-FF000000-None-FF000000-None-FF000000-None-FF000000-False-False NumberFormat: 14- Alignment: General-Bottom-0-False-ContextDependent-0-False-0-False- Protection: Locked} Value: 'rdsWorkbook.Worksheet("Sheet1").Range("A2").FirstCell().Value' threw an exception of type 'System.FormatException' ValueCached: null Worksheet: {'Sheet1'!A1:XFD1048576}

Edited Unassigned: Getting the Value for a Date Throws System.Format Exception [9356]

$
0
0
Getting the Value for a Date Cell thows a System.FormatException

New Post: Pivot table "Value Field Settings"

$
0
0
Hey there.

I've been trying to use ClosedXML to generate a group of Excel files systematically.

One of the tabs contains a Pivot Table that I was already able to add but I can't find a way to set the fields to "Show values as % of Column Total", this is an option that can be selected by going to "Options -> Show Values As" when the Pivot Table is selected.

Is it possible to do this with ClosedXML?

Thank you for your help and for the great tool you have developed!
Viewing all 1877 articles
Browse latest View live


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