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

Edited Unassigned: Issue while copying worksheets [9333]

$
0
0
Hi,

I am trying to copy worksheets from one workbook to another. But AddWorksheet() & copyTo() methods throws "An item with the same key has already been added" exception while copying.

can anyone figure it out, what is the issue???

Here is the code:
```
var workbook = new XLWorkbook();
WriteStaticSheets(workbook);

public void WriteStaticSheets(XLWorkbook wb)
{
var workbookTemplate = new XLWorkbook("D:\\test.xlsx");
foreach(var ws in workbookTemplate.Worksheets)
{
wb.AddWorksheet(ws); // throws "An item with the same key has already been added" exception
ws.CopyTo(wb,ws.Name); //even this throws the same exception
}
}
```

New Post: Issue while copying worksheets

$
0
0
Hi,

I am trying to copy worksheets from one workbook to another. But AddWorksheet() & copyTo() methods throws "An item with the same key has already been added" exception while copying.

can anyone figure it out, what is the issue???

Here is the code:
var workbook = new XLWorkbook();
WriteStaticSheets(workbook);

public void WriteStaticSheets(XLWorkbook wb)
{
            var workbookTemplate = new XLWorkbook("D:\\test.xlsx");
            foreach(var ws in workbookTemplate.Worksheets)
            {
                wb.AddWorksheet(ws); // throws "An item with the same key has already been added" exception
                 ws.CopyTo(wb,ws.Name);  //even this throws the same exception
            }
}

New Post: Issue while copying worksheets

$
0
0
There's already a sheet with the same name in the workbook.

Closed Unassigned: Issue while copying worksheets [9333]

$
0
0
Hi,

I am trying to copy worksheets from one workbook to another. But AddWorksheet() & copyTo() methods throws "An item with the same key has already been added" exception while copying.

can anyone figure it out, what is the issue???

Here is the code:
```
var workbook = new XLWorkbook();
WriteStaticSheets(workbook);

public void WriteStaticSheets(XLWorkbook wb)
{
var workbookTemplate = new XLWorkbook("D:\\test.xlsx");
foreach(var ws in workbookTemplate.Worksheets)
{
wb.AddWorksheet(ws); // throws "An item with the same key has already been added" exception
ws.CopyTo(wb,ws.Name); //even this throws the same exception
}
}
```
Comments: There's already a sheet with the same name in the workbook.

Source code checked in, #f0298199750f1ab5a2ef1903cbe8d470aa53ea5d

$
0
0
Fix worksheets not calling global named ranges created by another worksheet.

New Post: calc value from NamedRange between different worksheet

Commented Unassigned: Problem inserting Conditional Formulas [9332]

$
0
0
Hi,

I finding issues in inserting conditional formulas in closed xml.

For Example:
If I want to insert following formula into excel sheet
=IF(A1 > 0, Yes, No)

It appears as =IF(A1 > 0 ; Yes ; No) which is not supported in Microsoft Excel. It says formula is corrupt.

Can anyone help me??


.............................................................................................................................................

Thanks for the reply MDeLeon...

I even tried this. But the actual problem is SetFormulaA1 method is replacing the ","(Comma) with ";"(Semicolon) in the syntax while inserting the formula into the excel sheet, which is wrong in MS Excel.

SetFormulaA1("IF(A1>0,TRUE,FALSE)")
What I am getting from SetFormulaA1: IF(A1>0; TRUE; FALSE) //this doenst work in MS excel

MS Excel Syntax: IF(A1>0, TRUE, FALSE)

How to get the formula as it is...



Comments: What's your locale?

Source code checked in, #ee0f677189772b07f714fa6bbf4d6c86925503e0


New Post: PivotTable row and column labels broken by recent change?

Closed Unassigned: XLSM save file get corrupted [9331]

$
0
0
I'm using Closed XML for .Net 4.0 with Macro Enabled Excel, In the sheet I have some buttons, these buttons attached to macros, after opening and then saving the document using closed XML it get corrupted.

Steps:
1- Run an application that opens the xlsm sheet and saving it using the code below:
var workbook = new XLWorkbook("original.xlsm");
workbook.SaveAs("cotrrpted after save.xlsm");

2- Open the save document sand then save it using Excel.
3- when try to open the document again it shows an error.

You can find the orignal and result files in the followig link or you can find them attached
https://drive.google.com/file/d/0B7EHvjiS0C8GYWdFSkFwZ3U4S28/edit?usp=sharing
https://drive.google.com/file/d/0B7EHvjiS0C8GUGtIbF84Mk1mZlk/edit?usp=sharing




I attached the files for preview
Comments: Cannot reproduce.

Released: ClosedXML 0.73.0 (Jun 24, 2014)

$
0
0
ee0f67718977
Fix pivot table fields

f0298199750f
Fix worksheets not calling global named ranges created by another worksheet.

66c12538bf5e
Fixed a bug with formulas and strings

b07f23417458
Quick fix

37812ba6ddd3
Memory and performance improvements

c07fba026165
AdjustToContents and cell.GetFormattedString now use formulas

19e5940149b1
Add cell.NewDataValidation method

86980adfe487
Fix OutsideBorder and OutsideBorderColor for Conditional Formats

Created Release: ClosedXML 0.73.0 (Jun 24, 2014)

$
0
0
ee0f67718977
Fix pivot table fields

f0298199750f
Fix worksheets not calling global named ranges created by another worksheet.

66c12538bf5e
Fixed a bug with formulas and strings

b07f23417458
Quick fix

37812ba6ddd3
Memory and performance improvements

c07fba026165
AdjustToContents and cell.GetFormattedString now use formulas

19e5940149b1
Add cell.NewDataValidation method

86980adfe487
Fix OutsideBorder and OutsideBorderColor for Conditional Formats

New Post: PivotTable row and column labels broken by recent change?

$
0
0
Great, thanks, I can confirm the latest NuGet (0.73.0) works fine in my system.

Reviewed: ClosedXML 0.73.0 (六月 24, 2014)

$
0
0
Rated 5 Stars (out of 5) - Very Good!

New Post: Worksheet Copy to another will lost the name of named cell?

$
0
0
Hi,
There have two workbook and
workbookA has some named cell in sheet1 and when I copy to the sheet1 to another workbook
then I found the name of the named cell will be lost in the WorkbookB.

I'm not sure this is the supposed work but I think mybe should save their named will be better. :-D

New Post: Issue while copying worksheets

$
0
0
MDeLeon.. Thanks for the reply..

That workbook doesnt have any worksheets in it.. I am getting the same error even I change it to following code.
public void WriteStaticSheets(XLWorkbook wb)
        {
            var workbookTemplate = new XLWorkbook("D:\\BIP Forecast Template - Guide.xlsx");
           foreach(var ws in workbookTemplate.Worksheets)
            {
                if (!wb.Worksheets.Where(x => x.Name == ws.Name).Any())
                {
                    wb.AddWorksheet(ws);
                }
            }
        }

New Post: Issue while copying worksheets

$
0
0
Your code does the following.
1) find a worksheet in the workbook
2) add that worksheet into the same workbook without changing the name

The result is that it finds that a worksheet already exists in the workbook with that name.
You need to give it a new name when you make the copy.
You would need to do "ws.CopyTo(wb,"NewName");
or "ws.CopyTo("NewName");

Check out the documentation https://closedxml.codeplex.com/wikipage?title=Copying%20Worksheets

Created Unassigned: Named Reference Conaining Table or Formula Produces Ranges Exception [9334]

$
0
0
If I have defined a name that refers to a table range or formula, the ranges property produces an "Invalid Operation Exception"

For example

Name -> ProductionNightDay
RefersTo -> ProductionTable[[Nightshift]:[Dayshift]]
Ranges -> See Exception below
Is there a way to catch this without an exception?


System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Sequence contains no matching element
Source=System.Core
StackTrace:
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at ClosedXML.Excel.XLNamedRange.<get_Ranges>b__6(<>f__AnonymousType4`2 <>h__TransparentIdentifier2)
at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at ClosedXML.Excel.XLNamedRange.get_Ranges()
at ClosedXML.Excel.XLWorksheet.Range(String rangeAddressStr)
at ClosedXML.Excel.XLWorksheet.ClosedXML.Excel.IXLWorksheet.Range(String rangeAddress)
at TestBid.Program.Main(String[] args) in C:\Users\user\Documents\Visual Studio 2010\Projects\Test\Test\Program.cs:line 34
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
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()
InnerException:

New Post: Issue while copying worksheets

$
0
0
roberttanenbaum,

If you notice, my code doesn't add the worksheet into the same workbook, instead it adds into the workbook wb which is sent as a parameter.

I even tried with ws.CopyTo(wb,"NewName"), but still getting the same exception.

New Post: Issue while copying worksheets

$
0
0
I got the same exception but there are not exist the same name sheet.
Interesting and there are two sheet in workbook A,named 'Sheet999' and 'Travel',one of this sheet 'Sheet999' can be copy to another workbook correctly ,but the other one has throw the exception.(An item with the same key has already been added)

And i give the example code here :
( http://www.liuzhiyong2012.cn/dl/ClosedXML_0626.rar )
Viewing all 1877 articles
Browse latest View live


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