Reviewed: ClosedXML 0.69.1 (Mar 28, 2014)
New Post: Referring a formula in another worksheet
cell.SetFormulaA1("SUM('sheet1'!C8:'sheet1'!J8) + SUM('sheet2'!C9:'sheet2'!J9)");
to set a formula that uses other worksheets.
But then when I do this:
string content;
if (!cell.TryGetValue(out content)
{
...
}
it throws an exception.
What am I doing wrong?
New Post: Append to excel file
I have an excel file (created with ClosedXML library) and I want to append new rows to existing excel file (same format as the original).
I was thinking about reading the original file and get the data, get the new data and save them all together in a file.
Is there other (maybe better) way to do this that I am missing?
Thanks!
New Comment on "Pivot Table example"
New Post: Add datatable in customstarting cell range
wb.Worksheets.Add(dataTable, "Data")
but I need to add the date range in the first 2 cells of my xml. I tried to add the datatable, copy the whole data a couple of cells below, but I lose the sorting function in the excel.
How can I add the dataTable in another location? Or how can I move a range of cells without losing the sorting header cell?
Thank you a lot!
New Post: Turn off header filtering
Thanks
New Post: Turn off header filtering
DataTable dt = ds.Tables[0];
var clsXLWorkbook = new XLWorkbook();
var ws = clsXLWorkbook.Worksheets.Add(dt);
ws.Tables.First().ShowAutoFilter = false;
Commented Unassigned: WorkSheet CopyTo doesn't transform Named Ranges addresses [9270]
```
IXLWorksheet worksheet = modelSheet.CopyTo("SheetName");
```
When I open the generated document the NamedRanges were copied, using the same name as expected, but all of them are associated to the model worksheet (source). I was expecting the NamedRange address to be changed to the target Worksheet too.
Example:
```
"=ModelSheet!$B$10:$B$10" would transform to "=TargetSheet!$B$10:$B$10"
```
Is there a way to do it or isn't it supported yet?
Many Thanks & great work my man, incredible Lib!
Cheers!
Comments: ** Comment from web user: Rynkadink **
Meanwhile... I did create an Extension Method as a workaround;
It might be usefull to someone else:
```
public static class ClosedXml
{
public static IXLWorksheet CopyToWithNamedRanges(this IXLWorksheet sourceSheet, String targetSheetName)
{
if (sourceSheet == null)
{
throw new ArgumentNullException("Source Worksheet is Null!");
}
// # Call ClosedXML API CopyTo method
IXLWorksheet targetWorksheet = sourceSheet.CopyTo(sourceSheet.Workbook, targetSheetName);
// # Process copied Worksheet NamedRanges,
// Change Address reference replacing the source Worksheet name with newly created
// Worksheet (by copy) name.
foreach (IXLNamedRange namedRange in targetWorksheet.NamedRanges.Select(r => r))
{
// Get the source worksheet name from address
string[] splitAddress = namedRange.RefersTo.Split(new char[] { '!' }, 2);
string worksheetName = splitAddress[0];
// Enclose the target worksheet name in single quotes
string targetWorksheetName = String.Format("'{0}'", targetWorksheet.Name);
// Change the range reference address
namedRange.RefersTo = namedRange.RefersTo.Replace(worksheetName, targetWorksheetName);
}
return targetWorksheet;
}
}
```
New Post: Table & Charting
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Sample Sheet");
WorksheetPart worksheetPart = getWorksheetPart(worksheet);
where the method getWorksheetPart performed some sort of reflection on the worksheet object to access the underlying WorksheetPart? Or would that be a bad idea?New Post: Cells.InsertDataTable Time values are recognized as String
Many thanks in advance. :)
Source code checked in, #80797
Source code checked in, #80799
Source code checked in, #80800
New Comment on "Documentation"
Commented Unassigned: Pivot Tables Values Problem [9088]
Excellent example . It works perfect, but if you add more than one value will have a problem . Here I leave an example to reproduce the problem . Suppose Pastry class has one more property called "Amount" int
Step 1. Add two values
```
// The values in our table will come from the " NumberOfOrders " field
// The default setting is a full calculation of each row / column
pt.Values.Add ("NumberOfOrders");
// Another value ( THIS IS THE ONE THAT CAUSE THE PROBLEM )
pt.Values.Add ("Amount" ) ;
```
Step 2. Save the excel file
Step 3. Open the excel file , and throw the following message
We found a problem with Content ' Patry.xlsx ' . Do you want to try to recover as much content as possible ? If trusts origin of this book , please click yes .
Click yes, and I'll get the following message :
Removed Feature: PivotTable report from / xl / PivotTables / pivotTable.xml part ( PivotTable view)
Records removed : book Properties / xl / workbook.xml part ( Book)
Step 4. Final result , the pivot table is not generated
aTTACH project C# for reproduce problem.
Please expect your help to solve this problem .. thank you very much
Comments: ** Comment from web user: freakinhuge **
Has anyone been able to get this to work yet? I really need to make a pivot table with multiple value fields and it seems that everything out there can't do it..
Commented Unassigned: Pivot Tables Values Problem [9088]
Excellent example . It works perfect, but if you add more than one value will have a problem . Here I leave an example to reproduce the problem . Suppose Pastry class has one more property called "Amount" int
Step 1. Add two values
```
// The values in our table will come from the " NumberOfOrders " field
// The default setting is a full calculation of each row / column
pt.Values.Add ("NumberOfOrders");
// Another value ( THIS IS THE ONE THAT CAUSE THE PROBLEM )
pt.Values.Add ("Amount" ) ;
```
Step 2. Save the excel file
Step 3. Open the excel file , and throw the following message
We found a problem with Content ' Patry.xlsx ' . Do you want to try to recover as much content as possible ? If trusts origin of this book , please click yes .
Click yes, and I'll get the following message :
Removed Feature: PivotTable report from / xl / PivotTables / pivotTable.xml part ( PivotTable view)
Records removed : book Properties / xl / workbook.xml part ( Book)
Step 4. Final result , the pivot table is not generated
aTTACH project C# for reproduce problem.
Please expect your help to solve this problem .. thank you very much
Comments: ** Comment from web user: estyfen **
It has not yet been fixed. Finally I decided to explain to my clients, they must manually add the columns to the dynamic table to complete. :)
Reviewed: ClosedXML 0.69.1 (Apr 09, 2014)
Created Unassigned: Setting of Initial Zoom of Spreadsheet [9289]
The following discussion goes into a bit more detail of how the feature could be implemented
https://closedxml.codeplex.com/discussions/249997