I understand that working with DrawingsPart isn't supported, but it would be very useful in my situation to have that part copied when I use CopyTo to duplicate a worksheet. As it stands now, the new worksheet is missing the charts and images from the source worksheet.
↧
Created Unassigned: IXLWorksheet.CopyTo doesn't copy DrawingsPart [9472]
↧
Commented Unassigned: IXLWorksheet.CopyTo doesn't copy DrawingsPart [9472]
I understand that working with DrawingsPart isn't supported, but it would be very useful in my situation to have that part copied when I use CopyTo to duplicate a worksheet. As it stands now, the new worksheet is missing the charts and images from the source worksheet.
Comments: I'm taking a look at [this blog post](http://blogs.msdn.com/b/brian_jones/archive/2009/02/19/how-to-copy-a-worksheet-within-a-workbook.aspx) to potentially do the worksheet duplication before I process the worksheets with ClosedXML.
Comments: I'm taking a look at [this blog post](http://blogs.msdn.com/b/brian_jones/archive/2009/02/19/how-to-copy-a-worksheet-within-a-workbook.aspx) to potentially do the worksheet duplication before I process the worksheets with ClosedXML.
↧
↧
Commented Unassigned: Out Of Memory Creating file [9470]
I am creating an excel file. I cannot seem to get more than 100,000 rows total per workbook before getting an out memory exception. I have turned tracking off.
What do I need to supply to help you give me direction on how to solve this?
Comments: This was simple to solve. I was using Visual Studio 2015 and running the IISEXPRESS process in debug mode under VS2015. A simple option in VS 2015 called "Use the 64-bit version of IIS Express in web sites and projects" cured all my out-of-memory exceptions and I'm able to hold both the datatable and workbook and sheets in memory. Will it scale? Yes, across the small number of users we have. Worst case it will be slow, but task is a background "fire and forget" task, notifying the user when the job is complete.
What do I need to supply to help you give me direction on how to solve this?
Comments: This was simple to solve. I was using Visual Studio 2015 and running the IISEXPRESS process in debug mode under VS2015. A simple option in VS 2015 called "Use the 64-bit version of IIS Express in web sites and projects" cured all my out-of-memory exceptions and I'm able to hold both the datatable and workbook and sheets in memory. Will it scale? Yes, across the small number of users we have. Worst case it will be slow, but task is a background "fire and forget" task, notifying the user when the job is complete.
↧
New Post: Error
var sortState = new SortState
{
Reference =
filterRange.Range(filterRange.FirstCell().CellBelow(), filterRange.LastCell()).RangeAddress. //Why CellBelow()?
ToString()
};
↧
Commented Unassigned: Hide does not hide Worksheet [9453]
Can someone explain why the code below does not actually hide the worksheet?
workbook.Worksheet("Saber Tooth Audit Legend").Hide();
workbook.Worksheet("Saber Tooth Audit Legend").Visibility = XLWorksheetVisibility.Hidden;
workbook.SaveAs(destination);
Does Hide not actually Hide? When I open the Excel file it's worse than not hidden the focus is set to that tab in particular. What the heck is going on?
Also when I Unhide a worksheet it does not Unhide().
Is it my code?
Comments: Any update on this? I'm having the same issue. Not sure if this is the problem or not, but the value of the ClosedXML constants don't match the associated constants in Excel: ClosedXML XLWorksheetVisibility.Visible = 0 XLWorksheetVisibility.Hidden = 1 XLWorksheetVisibility.VeryHidden = 2 Excel xlSheetVisible = -1 xlSheetHidden = 0 xlSheetVeryHidden = 2
workbook.Worksheet("Saber Tooth Audit Legend").Hide();
workbook.Worksheet("Saber Tooth Audit Legend").Visibility = XLWorksheetVisibility.Hidden;
workbook.SaveAs(destination);
Does Hide not actually Hide? When I open the Excel file it's worse than not hidden the focus is set to that tab in particular. What the heck is going on?
Also when I Unhide a worksheet it does not Unhide().
Is it my code?
Comments: Any update on this? I'm having the same issue. Not sure if this is the problem or not, but the value of the ClosedXML constants don't match the associated constants in Excel: ClosedXML XLWorksheetVisibility.Visible = 0 XLWorksheetVisibility.Hidden = 1 XLWorksheetVisibility.VeryHidden = 2 Excel xlSheetVisible = -1 xlSheetHidden = 0 xlSheetVeryHidden = 2
↧
↧
Created Unassigned: ASPNETCOMPILER: Type 'DocumentFormat.OpenXml.OpenXmlElement' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'DocumentFormat.OpenXml.OpenXmlElement' to remove references to itself. [9473]
TFS deployment run to error:
ASPNETCOMPILER: Type 'DocumentFormat.OpenXml.OpenXmlElement' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'DocumentFormat.OpenXml.OpenXmlElement' to remove references to itself.
ASPNETCOMPILER: Type 'DocumentFormat.OpenXml.OpenXmlElement' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'DocumentFormat.OpenXml.OpenXmlElement' to remove references to itself.
↧
Edited Unassigned: ASPNETCOMPILER [9473]
TFS deployment run to error:
ASPNETCOMPILER: Type 'DocumentFormat.OpenXml.OpenXmlElement' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'DocumentFormat.OpenXml.OpenXmlElement' to remove references to itself.
ASPNETCOMPILER: Type 'DocumentFormat.OpenXml.OpenXmlElement' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'DocumentFormat.OpenXml.OpenXmlElement' to remove references to itself.
↧
Commented Unassigned: Error when i try release my project using CodeXML [9471]
When i try release my project, the error is in spanish and say
__Advertencia 1 La referencia principal "ClosedXML" no se pudo resolver porque se generó con la versión de .NET Framework ".NETFramework,Version=v4.0,Profile=Client". Esta es una versión posterior a la versión de .NET Framework de destino actual ".NETFramework,Version=v3.5". spirit
__
But, when i try to install the .Net Framewor 4.0 it say me " this version was intalled"
Please help me, thank in advance.
Comments: It seems that your visual studio "spirit" project targets .Net 3.5 instead of 4.0. Try checking in the properties of the project , in the "Application" tab if the "Target framework" correctly target .Net Framework 4.0 or not (see example in the attached image).
__Advertencia 1 La referencia principal "ClosedXML" no se pudo resolver porque se generó con la versión de .NET Framework ".NETFramework,Version=v4.0,Profile=Client". Esta es una versión posterior a la versión de .NET Framework de destino actual ".NETFramework,Version=v3.5". spirit
__
But, when i try to install the .Net Framewor 4.0 it say me " this version was intalled"
Please help me, thank in advance.
Comments: It seems that your visual studio "spirit" project targets .Net 3.5 instead of 4.0. Try checking in the properties of the project , in the "Application" tab if the "Target framework" correctly target .Net Framework 4.0 or not (see example in the attached image).
↧
New Post: Lost header and footer when copy worksheet
any plans to add support for images any time soon? would be super useful to my situation where I need to have a logo in the header. thanks!
↧
↧
New Comment on "Adding DataTable as Worksheet"
It seems that the actual creating of rows/columns for the sheet occurs during the workbook save process. There doesn't seem to be a way to insert content on the worksheet prior to the save.
↧
Created Unassigned: Read Excel [9474]
I am trying to read excel and convert it to DataTable but getting error in first statement itself
var workbook = new XLWorkbook(filePath);
or
var stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
var workbook = new XLWorkbook(stream);
Exception: Value cannot be null. Parameter name: source
Any help?
var workbook = new XLWorkbook(filePath);
or
var stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
var workbook = new XLWorkbook(stream);
Exception: Value cannot be null. Parameter name: source
Any help?
↧
New Post: Many dataset to one sheet
Hi,
I know how to save one dataset/datatable in one excel sheet (eg. wb.Worksheets.Add(GetData("EXCEL"), "Shipments")). But is it possible to save eg. 3 datasets in one sheet? I have StoredProc which returns 3 small datatables (about 20 rows each) and would be fine to save it in one sheet.
BR,
Thomas
I know how to save one dataset/datatable in one excel sheet (eg. wb.Worksheets.Add(GetData("EXCEL"), "Shipments")). But is it possible to save eg. 3 datasets in one sheet? I have StoredProc which returns 3 small datatables (about 20 rows each) and would be fine to save it in one sheet.
BR,
Thomas
↧
Reviewed: ClosedXML 0.76.0 (Jan 20, 2016)
Rated 5 Stars (out of 5) - Wow, easy to use
↧
↧
New Comment on "Conditional Formatting"
hi.
I'm in argentina. Inmy Excel App, i use a formula "=PROMEDIO(10;2)" but in english its AVERAGE but if i use AVERAGE i have an error. How must do with this issues ?
↧
New Post: Disable auto formating creating a Excel file
Hi,
I have a problem that some values look like dates ("12-01-00-06") and the api is converting them to custom date time format and messes the data up.
I have tried this:
worksheet.Cell("A2").DataType = XLCellValues.Text;
but this doesn't help and in debugger I see that after I assign the value then te dataType is set to DateTime.
How can I disable auto formattingfrom my sheet and show values as they are.
In Excel I also see that that the format is set to custom dateTime.
Kristjan.
I have a problem that some values look like dates ("12-01-00-06") and the api is converting them to custom date time format and messes the data up.
I have tried this:
worksheet.Cell("A2").DataType = XLCellValues.Text;
but this doesn't help and in debugger I see that after I assign the value then te dataType is set to DateTime.
How can I disable auto formattingfrom my sheet and show values as they are.
In Excel I also see that that the format is set to custom dateTime.
Kristjan.
↧
Created Unassigned: Incorrect formatting of many cells using Worksheet.CopyTo for first worksheet in new workbook [9475]
Hello,
I ran across an issue that took me several hours to narrow down what was actually happening, since it seemed very random. However, once I simplified my code, I finally found how to re-produce it and also a workaround for it. The issue that I'm having is that I have a file called "Resources.xlsx" that contains 5 worksheets, 2 of which are Templates that are formatted exactly how I want them to be, but the values are left blank. I want to use these 2 unique templates to create workbooks with many of the templates copied and then populated. However, an issue occurs where many cells in the first worksheet of the new workbook are formatted incorrectly.
The exact thing that I'm finding is happening is that it seems to be combining all formatting from the first 3 or 4 rows of the spreadsheet that are being used, so the first 3 or 4 rows from FirstRowUsed() basically, and once it combines the formatting from those cells, it places that format on every other cell in the worksheet that is in a blank row. But it only seems to insert the formatting from column A to the LastColumnUsed(). This ONLY seems to happen to the first worksheet, and all other worksheets copied from the same template are fine. I did have it happen where it changed the format in all worksheets, but I cannot replicate it.
Now my workaround has 2 options that both seem to work. My first test that worked was to use CopyTo to copy the first worksheet as normal, but then use SaveAs on the new workbook, then assign the workbook to the newly created file, and then Delete the first worksheet. Then I could copy all of the worksheets and all would be ok. However, if I simply created an empty sheet, that did NOT fix it. So this showed me that even if I deleted the first worksheet it would be fine, but only if I copied the sheet from that template. So it seemed to only be the first time that template was copied into the workbook.
My second workaround is much easier and simpler. When the template is moved to the first worksheet in the workbook, the issue seems to go away. So instead of having one file called Resources.xlsx with my Expense Voucher Template and my Travel Voucher Template, I'll now have a separate workbook for each template, so it will be the first sheet in its own workbook.
So it seems that when a worksheet is not the first one in a workbook, and is copied to a new workbook, the first worksheet copied takes the first 3 or 4 rows from FirstRowUsed() and places that formatting in all empty rows in the worksheet, from column A to LastColumnUsed().
I'm attaching my Resources.xlsx file, and below is my code. My 2 templates are the ones I mentioned above, Expense Voucher Template and Travel Voucher Template. In my code I'm only using Expense Voucher but it still illustrates the issue. Specifically notice the cells in the range E4:F6. If I remove the border and remove the Bold font type, it also removes border and Bold type from all cells in the first copied worksheet.
Thanks!
Paul
Here's the code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClosedXML.Excel;
using DocumentFormat.OpenXml.Office.Excel;
using System.IO;
namespace TestingAnything
{
class Program
{
XLWorkbook travelVouchersWkBk = null;
IXLWorksheet travelVoucherTemplate = null;
static void Main(string[] args)
{
Program p = new Program();
p.run();
}
private void run()
{
if (File.Exists("./TravelVouchers.xlsx")) File.Delete("./TravelVouchers.xlsx");
XLWorkbook wb = new XLWorkbook("./Resources.xlsx");
travelVoucherTemplate = wb.Worksheet("Expense Voucher Template");
IXLWorksheet vendorSheet = travelVoucherTemplate.CopyTo(travelVouchersWkBk, "test");
if (!File.Exists("./TravelVouchers.xlsx"))
{
travelVouchersWkBk.SaveAs("./TravelVouchers.xlsx");
travelVouchersWkBk = new XLWorkbook("./TravelVouchers.xlsx");
}
else travelVouchersWkBk.Save();
}
}
}
```
I ran across an issue that took me several hours to narrow down what was actually happening, since it seemed very random. However, once I simplified my code, I finally found how to re-produce it and also a workaround for it. The issue that I'm having is that I have a file called "Resources.xlsx" that contains 5 worksheets, 2 of which are Templates that are formatted exactly how I want them to be, but the values are left blank. I want to use these 2 unique templates to create workbooks with many of the templates copied and then populated. However, an issue occurs where many cells in the first worksheet of the new workbook are formatted incorrectly.
The exact thing that I'm finding is happening is that it seems to be combining all formatting from the first 3 or 4 rows of the spreadsheet that are being used, so the first 3 or 4 rows from FirstRowUsed() basically, and once it combines the formatting from those cells, it places that format on every other cell in the worksheet that is in a blank row. But it only seems to insert the formatting from column A to the LastColumnUsed(). This ONLY seems to happen to the first worksheet, and all other worksheets copied from the same template are fine. I did have it happen where it changed the format in all worksheets, but I cannot replicate it.
Now my workaround has 2 options that both seem to work. My first test that worked was to use CopyTo to copy the first worksheet as normal, but then use SaveAs on the new workbook, then assign the workbook to the newly created file, and then Delete the first worksheet. Then I could copy all of the worksheets and all would be ok. However, if I simply created an empty sheet, that did NOT fix it. So this showed me that even if I deleted the first worksheet it would be fine, but only if I copied the sheet from that template. So it seemed to only be the first time that template was copied into the workbook.
My second workaround is much easier and simpler. When the template is moved to the first worksheet in the workbook, the issue seems to go away. So instead of having one file called Resources.xlsx with my Expense Voucher Template and my Travel Voucher Template, I'll now have a separate workbook for each template, so it will be the first sheet in its own workbook.
So it seems that when a worksheet is not the first one in a workbook, and is copied to a new workbook, the first worksheet copied takes the first 3 or 4 rows from FirstRowUsed() and places that formatting in all empty rows in the worksheet, from column A to LastColumnUsed().
I'm attaching my Resources.xlsx file, and below is my code. My 2 templates are the ones I mentioned above, Expense Voucher Template and Travel Voucher Template. In my code I'm only using Expense Voucher but it still illustrates the issue. Specifically notice the cells in the range E4:F6. If I remove the border and remove the Bold font type, it also removes border and Bold type from all cells in the first copied worksheet.
Thanks!
Paul
Here's the code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClosedXML.Excel;
using DocumentFormat.OpenXml.Office.Excel;
using System.IO;
namespace TestingAnything
{
class Program
{
XLWorkbook travelVouchersWkBk = null;
IXLWorksheet travelVoucherTemplate = null;
static void Main(string[] args)
{
Program p = new Program();
p.run();
}
private void run()
{
if (File.Exists("./TravelVouchers.xlsx")) File.Delete("./TravelVouchers.xlsx");
XLWorkbook wb = new XLWorkbook("./Resources.xlsx");
travelVoucherTemplate = wb.Worksheet("Expense Voucher Template");
IXLWorksheet vendorSheet = travelVoucherTemplate.CopyTo(travelVouchersWkBk, "test");
if (!File.Exists("./TravelVouchers.xlsx"))
{
travelVouchersWkBk.SaveAs("./TravelVouchers.xlsx");
travelVouchersWkBk = new XLWorkbook("./TravelVouchers.xlsx");
}
else travelVouchersWkBk.Save();
}
}
}
```
↧
New Post: Formulas in datatable from Database
Is there a way to tell ClosedXML to look for Formulas in the data table and process them accordingly? Currently my database call returns a data table that contains an =HYPERLINK formula and it shows up as the full formula rather than the link on the exported spreadsheet.
Thanks!
Thanks!
↧
↧
New Post: Problem with the formula
Replace the Semicolons ";" with commas "," to read like this:
worksheets.Cell(2, 2).FormulaA1 = "=IF(A6>$A$4,0,1-(E6+F6)/C6)";
I will typically test out the formula manually in Excel to see if it works first, and then use it with the same syntax with ClosedXML.↧
New Post: Table & Charting
I know this is an old discussion, but I have browsed the sources and saw the XLChart exists, but it is not publicly exposed:
IXLWorksheet has it commented out.
Can anyone say what is the status of its development? I am asking this because I want to use the feature only to change a datasource for an existing chart in an Excel file.
Thank you.
IXLWorksheet has it commented out.
Can anyone say what is the status of its development? I am asking this because I want to use the feature only to change a datasource for an existing chart in an Excel file.
Thank you.
↧
New Post: Read excel file located at web server
Is it possible to read excel file located at web server using closed xml.
I have tried but it popped out "URI formats are not supported".
fName = "http://cip-mis.aviyaan.com/.........../a.xlsx"
Dim workbook = New ClosedXML.Excel.XLWorkbook(fName)
it says URI format not supported.
I have tried but it popped out "URI formats are not supported".
fName = "http://cip-mis.aviyaan.com/.........../a.xlsx"
Dim workbook = New ClosedXML.Excel.XLWorkbook(fName)
it says URI format not supported.
↧