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

Source code checked in, #15b07291258df096f323163ca917729c95d18c14

$
0
0
Merge branch 'ClearMergedCells' of https://git01.codeplex.com/forks/nicknack2020/closedxml into NickNack2020/ClosedXml

Source code checked in, #e13a65854169868f8eaded4c15351c7385a573a8

$
0
0
Merge branch 'NickNack2020/ClosedXml'

Closed Issue: XLCell.Clear(XLClearOptions.ContentsAndFormats) does not clear the border for merged cells properly [7925]

$
0
0
Greetings again. Please see the attached example. If you have a merged cell that is composed of say, B2:J17, and this cell (range really I guess) has a border around it, and you call wb.Worksheet(1).Cell("B2").Clear(XLClearOptions.ContentsAndFormats), *only* the border around B2 will be cleared, and not the entire range. Interestingly, if the merged cell has a background color, that DOES seem to be cleared.
Comments: Fixed.

Closed Issue: Null Reference on Loading File created by OpenXML [8631]

$
0
0
I've managed to create a very basic macro enabled spreadsheet via OpenXML (merging a VBA macro from another spreadsheet along the way).

The generated spreadsheet opens up correctly in Excel - the macro is present, together with the data I've put in there.

However, when I try to use ClosedXML to open the file, I get a "NullReferenceException was unhandled" error message appear.

Here's the code for opening the file:

var nwb = new XLWorkbook("C:\\Temp\\ExcelTest.xlsm");

I've attached the file.

Any help would be appreciated...
Comments: Fixed

Source code checked in, #06b54aa84ae2f9727fa07f53ed6376f4237eb7b2

$
0
0
Merge branch 'LoadComments' of https://git01.codeplex.com/forks/nicknack2020/closedxml into NickNack2020/ClosedXml

Source code checked in, #0f8aa9bee272ee54d97ea09d5eb6e147570ceed2

$
0
0
Merge branch 'NickNack2020/ClosedXml'

Closed Unassigned: InvalidOperationException when loading an Excel sheet with a funky comment. [9267]

$
0
0
See attached Excel sheet. When loading this sheet with ClosedXML, I receive the following error:

InvalidOperationException: Sequence contains no matching element

at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 334
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 47
at ClosedXML.Excel.XLWorkbook.Load(String file) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 36
at ClosedXML.Excel.XLWorkbook..ctor(String file, XLEventTracking eventTracking) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 626
at ClosedXML.Excel.XLWorkbook..ctor(String file) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 615
at ClosedXML_Sandbox.Program.Main(String[] args) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML_Sandbox\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

The error is located in this piece of code which handles comments:

```
var xml = xdoc.Root.Element("xml");
XElement shape;
if (xml != null)
shape = xml.Elements().First(e => (string)e.Attribute("type") == "#_x0000_t202");
else
shape = xdoc.Root.Elements().First(e => (string)e.Attribute("type") == "#_x0000_t202");
```
Somehow in our excel sheet, the comment has shape type #_x0000_t75. Which is also defined in the xdoc.

I quick fixed it for our situation by using FirstOrDefault and then checking if shape == null before continuing. But I think this could be handled more elegantly (since with my solution editing of the comment is not possible anymore).
Comments: fixed

Source code checked in, #35c801d518c3b457574d11d2f9386b223f2ef743


New Post: Protect Workbook

$
0
0
The latest code adds simple workbook protection (no password).

New Comment on "Headers and Footers Tab"

$
0
0
How to insert image in Header string imagePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/img/tuv-logo.jpg"); worksheet.PageSetup.Header.Right.AddImage(imagePath,XLHFOccurrence.FirstPage); above AddImage method gets error: The method or operation is not implemented.

Created Unassigned: How to Add Image In Header Using ClosedXML [9350]

$
0
0
Error At AddImage(imagePath,XLHFOccurrence.FirstPage);
Error : The method or operation is not implemented.

var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Covering Letter",1);
// worksheet = InsertHeaderFooter(worksheet);
//worksheet.PageSetup.Header.Right.AddText("THis is header");
string imagePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/img/tuv-logo.jpg");
worksheet.PageSetup.Header.Right.AddImage(imagePath,XLHFOccurrence.FirstPage);

Reviewed: ClosedXML 0.73.0 (Jul 28, 2014)

$
0
0
Rated 5 Stars (out of 5) - I have been using this library for a long time and can honestly say that it is one of the most useful tools I have ever used. It made the task of creating complex spreadsheets simple. No more COM, no more horrible raw OpenXML, just a nice easy to use library. Many thanks for your hard work !

Commented Unassigned: How to Add Image In Header Using ClosedXML [9350]

$
0
0
Error At AddImage(imagePath,XLHFOccurrence.FirstPage);
Error : The method or operation is not implemented.

var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Covering Letter",1);
// worksheet = InsertHeaderFooter(worksheet);
//worksheet.PageSetup.Header.Right.AddText("THis is header");
string imagePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/img/tuv-logo.jpg");
worksheet.PageSetup.Header.Right.AddImage(imagePath,XLHFOccurrence.FirstPage);
Comments: You can't: https://closedxml.codeplex.com/wikipage?title=How%20can%20I%20insert%20an%20image%3f&referringTitle=Documentation It is possible in OpenXML itself but it is horribly complex. An example of just inserting an image can be found here: http://user239.blogspot.co.uk/2011/03/how-to-insert-image-to-excel-document.html Maybe you can adapt it to work in a header.

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: Are you filling in reports whilst simultaneously adjusting to contents ? Can you not just call Adjust To Contents when your reports are all filled in ?

Created Unassigned: ClosedXML_v0.73.0.0 (.net 3.5)-worksheet.Columns().AdjustToContents(1) does not work for headers [9351]

$
0
0
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add(dt,"Sample Sheet");
worksheet.Columns().AdjustToContents(1);

In case headers in first row are longer than values, this code does not adjust rows so that headers are not trimmed. In v0.68.1.0 all things were fine (.net 3.5)

Created Unassigned: trying to save data to a database [9352]

$
0
0
I'm trying to save data to a database; excel was generated with ClosedXML.
The value of a cell through ClosedXML is not read. But I can not read a DataTable I want to generate for OleDb.
I need to read it from a web server and stored in the database. I need a help to solve the problem.

[link to a project](http://www.mediafire.com/download/2dep22dzuym9tas/ConsoleTest3.rar)

Thank you.
Hernan

Edited Issue: Null Reference on Loading File created by OpenXML [8631]

$
0
0
I've managed to create a very basic macro enabled spreadsheet via OpenXML (merging a VBA macro from another spreadsheet along the way).

The generated spreadsheet opens up correctly in Excel - the macro is present, together with the data I've put in there.

However, when I try to use ClosedXML to open the file, I get a "NullReferenceException was unhandled" error message appear.

Here's the code for opening the file:

var nwb = new XLWorkbook("C:\\Temp\\ExcelTest.xlsm");

I've attached the file.

Any help would be appreciated...

Edited Issue: XLCell.Clear(XLClearOptions.ContentsAndFormats) does not clear the border for merged cells properly [7925]

$
0
0
Greetings again. Please see the attached example. If you have a merged cell that is composed of say, B2:J17, and this cell (range really I guess) has a border around it, and you call wb.Worksheet(1).Cell("B2").Clear(XLClearOptions.ContentsAndFormats), *only* the border around B2 will be cleared, and not the entire range. Interestingly, if the merged cell has a background color, that DOES seem to be cleared.

Closed Issue: Issue with hyperlinks containing non-ASCII characters? [7832]

$
0
0
Hi there,
 
is there any known issue with hyperlinks containing non-ascii characters?
 
Example: currentRow.Cell(1).Hyperlink = new XLHyperlink(@"F:\Dokumentation\Versand\Rücklauf Extern\Außer.xls"); doesnt seem to work. Clicking the hyperlink in Excel doesn't open the file. Instead I keep gettting a message that the address is invalid.
 
The workbooks source shows this:
 
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///F:/Dokumentation/Versand/R%C3%BCcklauf%20Extern/Au%C3%9Fer.xls" TargetMode="External" Id="rId8" />
 
Any ideas?
 
Regards
Aleks
Comments: Pull request merged.

Edited Issue: InvalidOperationException when loading an Excel sheet with a funky comment. [9267]

$
0
0
See attached Excel sheet. When loading this sheet with ClosedXML, I receive the following error:

InvalidOperationException: Sequence contains no matching element

at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 334
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 47
at ClosedXML.Excel.XLWorkbook.Load(String file) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 36
at ClosedXML.Excel.XLWorkbook..ctor(String file, XLEventTracking eventTracking) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 626
at ClosedXML.Excel.XLWorkbook..ctor(String file) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 615
at ClosedXML_Sandbox.Program.Main(String[] args) in d:\Temp\closedxml-80652\ClosedXML\ClosedXML\ClosedXML_Sandbox\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

The error is located in this piece of code which handles comments:

```
var xml = xdoc.Root.Element("xml");
XElement shape;
if (xml != null)
shape = xml.Elements().First(e => (string)e.Attribute("type") == "#_x0000_t202");
else
shape = xdoc.Root.Elements().First(e => (string)e.Attribute("type") == "#_x0000_t202");
```
Somehow in our excel sheet, the comment has shape type #_x0000_t75. Which is also defined in the xdoc.

I quick fixed it for our situation by using FirstOrDefault and then checking if shape == null before continuing. But I think this could be handled more elegantly (since with my solution editing of the comment is not possible anymore).
Viewing all 1877 articles
Browse latest View live