Thank you for the quick response. I really appreciate it. Too bad; I was hoping it would work.
↧
New Post: Text File Imports
↧
New Post: Unable to get format data cell using closexml
using trygetvalue foreach cell in a great file program appear very slow.
have you a suggest to accelerate program?
i have to use trygetvalue in each cell because i don't konw which cell is date so i try for each cell but this slow down program
have you a suggest to accelerate program?
i have to use trygetvalue in each cell because i don't konw which cell is date so i try for each cell but this slow down program
↧
↧
New Post: using trygetvalue program is very slow
hi,
i have a problem using trygetvalue in a excel file.
using this function in each cell to undertsand if my cell is a data and in this case getting value, my program is very slow
without trygetvalue use time for one second to finish instead using trygetvalue in each cell use time for 30 seconds.
how can i bypass this problem?
thanks in advance
i have a problem using trygetvalue in a excel file.
using this function in each cell to undertsand if my cell is a data and in this case getting value, my program is very slow
without trygetvalue use time for one second to finish instead using trygetvalue in each cell use time for 30 seconds.
how can i bypass this problem?
thanks in advance
↧
New Post: Text File Imports
Yes, only you know what to expect when reading a text file ... what are the delimiters, how many columns, what type of values are in each column, so it is quite a lot to expect software to parse a plain text file and get it right. Excel tries and gets it wrong a significant number of times. Too often eliminating leading zeros for example.
However, I will say that if you parse each row into a well-constructed object. You can pass a list of those objects to the InsertTable method and you have the whole Excel sheet created with one method call. Headings and all.
Such simplicity can't be beat.
example:
sheet.Cell(1, 1).InsertTable(listOfRowObjects)
See this discussion:
https://closedxml.codeplex.com/discussions/251095
However, I will say that if you parse each row into a well-constructed object. You can pass a list of those objects to the InsertTable method and you have the whole Excel sheet created with one method call. Headings and all.
Such simplicity can't be beat.
example:
sheet.Cell(1, 1).InsertTable(listOfRowObjects)
See this discussion:
https://closedxml.codeplex.com/discussions/251095
↧
New Post: Text File Imports
roberttanenbaum: I'm sorry, no disrespect intended, but that is simply incorrect. I was using another library which also uses Open XML as its backbone and was able to import text files directly to a spreadsheet without issue. The only requirement was establishing what the import options were, and that was a simple line of code for each field. The import itself was a single line of code. I didn't have to parse anything; the library did it for me.
Additionally, there are other "helper" libraries which can handle parsing text files just fine. I ask the question here because ClosedXML worked great for handling data down from a database, but I didn't see anything in the documentation addressing text file imports. Now I know ClosedXML doesn't do them, and that's fine. It does what it can do very well. But the other library I use can do this also, and handle the text imports, so I guess for doing those things I'll have to stay with that one.
I don't mean to be argumentative, but I know for a fact some Open XML libraries can do this, out of the box. I use one now.
Additionally, there are other "helper" libraries which can handle parsing text files just fine. I ask the question here because ClosedXML worked great for handling data down from a database, but I didn't see anything in the documentation addressing text file imports. Now I know ClosedXML doesn't do them, and that's fine. It does what it can do very well. But the other library I use can do this also, and handle the text imports, so I guess for doing those things I'll have to stay with that one.
I don't mean to be argumentative, but I know for a fact some Open XML libraries can do this, out of the box. I use one now.
↧
↧
New Post: Text File Imports
Thank you. That's good to know.
↧
New Post: Check DataValidation
if the cell has a validation like currency and the values in 'usd,cny,eur,cad' and its a dropdowslist
But if the cell value displayed 'abc' and not in the currency ranges.
How can i check or get the error msg? thanks your help.
But if the cell value displayed 'abc' and not in the currency ranges.
How can i check or get the error msg? thanks your help.
↧
Created Unassigned: 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in System.Xml.dll [9391]
I'm trying to create a COM component using ClosedXML. It's working perfectly until I go to save the file. Everything works fine when I run a COM test under .NET, but when I connect it to VB6 it pitches the following error.
'System.IO.IsolatedStorage.IsolatedStorageException' occurred in System.Xml.dll
Unable to determine the identity of domain.
The files written are above 10MB. I've research this for about 2 weeks now and still haven't found a resolution.
'System.IO.IsolatedStorage.IsolatedStorageException' occurred in System.Xml.dll
Unable to determine the identity of domain.
The files written are above 10MB. I've research this for about 2 weeks now and still haven't found a resolution.
↧
New Post: Check DataValidation
With Excel, the program wouldn't let you select a value not in the list. With ClosedXML you're responsible for setting a valid value.
↧
↧
Created Unassigned: Cross-worksheet Cell and Range hyperlinks should work [9392]
The XLHyperlink constructor currently converts a Cell or Range into an address string __without the sheet name__. This means that cross-worksheet hyperlinks don't work correctly. If I create a hyperlink on Sheet1 to a Cell on Sheet2, then it gets saved out as a hyperlink to the cell address on Sheet1.
I'm attaching a patch that solves this problems by storing the Cell or Range. ToString is also overloaded so that it can include the sheet name. (ToStringFixed and ToStringRelative already have this overload, but they cannot be used because the Cell or Range may be either fixed or relative.)
I'm attaching a patch that solves this problems by storing the Cell or Range. ToString is also overloaded so that it can include the sheet name. (ToStringFixed and ToStringRelative already have this overload, but they cannot be used because the Cell or Range may be either fixed or relative.)
↧
New Post: Excel 2013 - 2010 compatibility
Hi first time posting, I figured out how to fix this after reading your posts above and this here
http://support.microsoft.com/kb/296492
TLDR see below for solution if you get the x' was an undeclared namespace problem that I did
1) Download notepad++ so you can edit your XML file easier, you can also choose to use regular notepad
2) For the noobs out there like me when I started this process - unpack the xlsx file by changing .xlsx extension to .zip, then unzip the zip to a folder since you can't edit files inside the zip folder (you will rezip later)
3) Open up the styles.xml file inside the xl folder using notepad++
3) Control find for "x:" to find instances where x is used as namespace
In my case, I found this:
<x:ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"> defaultTimelineStyle="TimeSlicerStyleLight1"/></x:ext>
Since there is an x15 after xmlns: I know the name space here should be x15 and not x (according to the microsoft.com link at the beginning of this post)
So the <x:ext... should be change to <x15:ext... and the </x:ext> should be changed to </x15:ext>
4) Make these changes to all instances of x: to the correct namespace and hit save on styles.xml
5) Rezip the excel folder and change .zip to .xlsx
6) Open the file in excel - this worked for me but no guarantee it would work for you
Message me if you have any questions - thanks for the clues
http://support.microsoft.com/kb/296492
TLDR see below for solution if you get the x' was an undeclared namespace problem that I did
1) Download notepad++ so you can edit your XML file easier, you can also choose to use regular notepad
2) For the noobs out there like me when I started this process - unpack the xlsx file by changing .xlsx extension to .zip, then unzip the zip to a folder since you can't edit files inside the zip folder (you will rezip later)
3) Open up the styles.xml file inside the xl folder using notepad++
3) Control find for "x:" to find instances where x is used as namespace
In my case, I found this:
<x:ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
Since there is an x15 after xmlns: I know the name space here should be x15 and not x (according to the microsoft.com link at the beginning of this post)
So the <x:ext... should be change to <x15:ext... and the </x:ext> should be changed to </x15:ext>
4) Make these changes to all instances of x: to the correct namespace and hit save on styles.xml
5) Rezip the excel folder and change .zip to .xlsx
6) Open the file in excel - this worked for me but no guarantee it would work for you
Message me if you have any questions - thanks for the clues
↧
New Comment on "Adding an AutoFilter to a Range"
ws.AutoFilter.clea() gives an error
An unhandled exception of type 'System.NullReferenceException' occurred in ClosedXML.dll
Additional information: Object reference not set to an instance of an object.
↧
New Comment on "Adding an AutoFilter to a Range"
ws.AutoFilter.clear() gives an error
An unhandled exception of type 'System.NullReferenceException' occurred in ClosedXML.dll
Additional information: Object reference not set to an instance of an object.
↧
↧
New Comment on "Adding DataTable as Worksheet"
How can I remove the filter setting.
↧
New Post: Get formula's value
http://closedxml.codeplex.com/workitem/7614
I have try get the valuecached but its null sometimes.
And do u have a good way to get the value ? Thank U.
I need your help.
I have try get the valuecached but its null sometimes.
And do u have a good way to get the value ? Thank U.
object objValue = null;
if (cell.HasFormula)
{
double tmpTime = 0;
if (type.Equals(typeof(DateTime)) && Double.TryParse(cell.ValueCached, out tmpTime))
objValue = DateTime.FromOADate(Convert.ToDouble(cell.ValueCached));
else
{
try
{
objValue = cell.Value;
}
catch
{
objValue = cell.ValueCached;
}
}
}
else
{
objValue = cell.Value;
}
because when i got the cell.Value directly it will throw the exception .I need your help.
↧
New Comment on "Adding DataTable as Worksheet"
found a way to remove filter.
var doc = new XLWorkbook() ;
var sheet1 = doc.Worksheets.Add(datatable)
sheet1.Table("Table1").ShowAutoFilter = false;
↧
Reviewed: ClosedXML 0.75.0 (Nov 20, 2014)
Rated 5 Stars (out of 5) - Thank you! This is excellent, really easy to use compared to the OpenXML SDK.
↧
↧
New Post: Loading SSRS Excel spreadsheet throws Object reference not set error
I'm loading the xlsx excel spreadsheet that was created from a SSRS report built using Sql Server Data Tools of Sql Server 2012. Has this happened to anyone else?
In this line:
XLWorkbook workbook = new XLWorkbook("TestReport.xlsx");
I get the following error.
System.NullReferenceException: Object reference not set to an instance of an object.
at ClosedXML.Excel.XLWorkbook.LoadCells(SharedStringItem[] sharedStrings, Stylesheet s, NumberingFormats numberingFormats, Fills fills, Borders borders, Fonts fonts, Dictionary
at ClosedXML.Excel.XLWorkbook.LoadRows(Stylesheet s, NumberingFormats numberingFormats, Fills fills, Borders borders, Fonts fonts, XLWorksheet ws, SharedStringItem[] sharedStrings, Dictionary
at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet)
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName)
at ClosedXML.Excel.XLWorkbook.Load(String file)
at ClosedXML.Excel.XLWorkbook..ctor(String file, XLEventTracking eventTracking)
at ClosedXML.Excel.XLWorkbook..ctor(String file)
In this line:
XLWorkbook workbook = new XLWorkbook("TestReport.xlsx");
I get the following error.
System.NullReferenceException: Object reference not set to an instance of an object.
at ClosedXML.Excel.XLWorkbook.LoadCells(SharedStringItem[] sharedStrings, Stylesheet s, NumberingFormats numberingFormats, Fills fills, Borders borders, Fonts fonts, Dictionary
2 sharedFormulasR1C1, XLWorksheet ws, Dictionary
2 styleList, Cell cell, Int32 rowIndex)at ClosedXML.Excel.XLWorkbook.LoadRows(Stylesheet s, NumberingFormats numberingFormats, Fills fills, Borders borders, Fonts fonts, XLWorksheet ws, SharedStringItem[] sharedStrings, Dictionary
2 sharedFormulasR1C1, Dictionary
2 styleList, Row row)at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet)
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName)
at ClosedXML.Excel.XLWorkbook.Load(String file)
at ClosedXML.Excel.XLWorkbook..ctor(String file, XLEventTracking eventTracking)
at ClosedXML.Excel.XLWorkbook..ctor(String file)
↧
Commented Unassigned: CopyTo one to another workbook style error [9389]
```
System.Collections.Generic.KeyNotFoundException
mscorlib.dll!System.Collections.Generic.Dictionary<int,System.__Canon>.this[int].get(int key) + 0x8a
> ClosedXML.dll!ClosedXML.Excel.XLWorkbook.GetStyleById(int id)
System.Core.dll!System.Linq.Enumerable.WhereSelectEnumerableIterator<int,System.__Canon>.MoveNext() + 0xc8
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.GenerateWorkbookStylesPartContent(DocumentFormat.OpenXml.Packaging.WorkbookStylesPart workbookStylesPart, ClosedXML.Excel.XLWorkbook.SaveContext context) 行 2443 + 0x8ae
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.CreateParts(DocumentFormat.OpenXml.Packaging.SpreadsheetDocument document) 行 139 + 0x1a
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.CreatePackage(string filePath, DocumentFormat.OpenXml.SpreadsheetDocumentType spreadsheetDocumentType) + 0x10
ClosedXML.dll!ClosedXML.Excel.XLWorkbook.SaveAs(string file) + 0x36
```
```
internal IXLStyle GetStyleById(Int32 id)
{
return _stylesById[id];
}
```
```
namespace Tests
{
class Program
{
static void Main(string[] args)
{
using (var d1 = new XLWorkbook("Server.xlsx"))
{
using (var ms = new MemoryStream())
{
using (var d2 = new XLWorkbook())
{
//spell_template
//wheel_progressive_template
//worn_weapon_seal_template
d1.Worksheet("wheel_progressive_template").CopyTo(d2, "wheel_progressive_template");
d2.SaveAs("Data2.xlsx");
//d2.SaveAs(ms);
}
}
}
}
}
}
```
Comments: workbook = new XLWorkbook(@"D:\Rapport\output2.xlsx"); var workbookRef = new XLWorkbook(docName); var wsSource = workbook.Worksheet(1); workbook.Worksheet(1).CopyTo(workbookRef, workbook.Worksheet(1).Name); // Save the workbook with the 2 copies workbookRef.SaveAs(@"D:\Rapport\CopyingWorksheets.xlsx"); Style and image are lost in the copied worksheet.
↧
New Comment on "Documentation"
This is brilliant! If we had something like this for word docs a couple of years ago the project I was one would have been cut in half!
↧