Free Support Forum - aspose.com

The same worksheet name already exists error

Received : 2007/09/07 09:19:07
Message : hi, i am using the latest version of the aspose.cells for .NET framework 2.0, i am getting this error stating "The same worksheet name already exists error". i never had the problem while using the older versions of the aspose.cells. i've read forums related to this error, did as it was stated in the forums, but couldnt get out of this error. if you need any further details please let me know. thanks. Vijay


This message was posted using Aspose.Live 2 Forum

Could you please post your sample code and template file here to help us to reproduce this problem? Thank you very much.

string file = path + Session.SessionID + ".xls";

string lic_path = "Aspose.Custom.lic";

Aspose.Cells.License lic = new Aspose.Cells.License();

lic.SetLicense(lic_path);

Workbook book1 = new Workbook();

Workbook book2 = new Workbook();

try

{

book1.Open(doc1);

book2.Open(doc2);

book1.Combine(book2);

book1.Save(file);

}

catch (Exception ex)

{

}

i tried to debug the code and found out that when i am trying to join to workbooks i get the error at the above highlighted statement..

Thanks

Vijay

the above mentioned code was workign fine with the previous version of aspose.cell v4.0.2.0 .. the problem started when i upgraded to the new version of aspose.cell v4.3.0.0..

thanks

Vijay

Hi Vijay,

The problem may be caused by that your two files have same worksheet name. I will check and fix this issue in the start of next week. Thanks for your patience.

Hi Laurence,

I have made sure that the file names of the two files are different by adding "pg1" and "pg2" respectively at the end of the file names. I appreciate for the quick response. Have a nice weekend.. i will be waiting for the fix.

Thanks

Vijay

Hey Laurence,

Quick question, what is the max lenght for the file name, currently my file name has 28 characters "5roaef2cm1epy5alkxgunoqo_pg1.xls" and "5roaef2cm1epy5alkxgunoqo_pg2.xls" is there any limitation for the file length, please let me know, so that i can look into the code to fix it.

Thanks

Vijay

Hi Vijay,

Well, I think there is no problem with your file names or their size. I tested a bit, there is no problem with Workbook.Combine method as it works fine.

Could you please post your both template files here. So, that we may check and figure out the issue.

Thank you.

Hi Amjad,

please find the files attached

Thanks

Vijay

Hey Amjad.. this is the exact error i am getting..

System.Exception was caught
Message="The same worksheet name already exists"
Source="Aspose.Cells"
StackTrace:
at Aspose.Cells.Worksheet.set_Name(String value)
at Aspose.Cells.Worksheets.xcc75e504ef58a07f(Worksheets xf71a0df303a78bf4)
at Aspose.Cells.Workbook.Combine(Workbook secondWorkbook)
at PNLMS.ViewSDFRept.mergeXLs(String doc1, String doc2, String path) in

Hi Vijay,

Thanks for the template files.

As Laurence told you that the problem may be caused by that your two files have same worksheet name. I checked the two files you posted i.e., "5roaef2cm1epy5alkxgunoqo_pg1.xls" and "5roaef2cm1epy5alkxgunoqo_pg2". Both templates have a worksheet named "Sheet1", So you must change the worksheet name of any workbook before combining them.

Following is my code which works fine:

const String temp1 = @"d:\test\5roaef2cm1epy5alkxgunoqo_pg1.xls";
const String temp2 = @"d:\test\5roaef2cm1epy5alkxgunoqo_pg2.xls";
FileStream fs = new FileStream(temp1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Workbook wb1 = new Workbook();
wb1.Open(fs, FileFormatType.Default);
Workbook wb2 = new Workbook(); ;
wb2.Open(temp2);
wb2.Worksheets[0].Name = "MySheet";
wb1.Combine(wb2);
wb1.Worksheets.ActiveSheetIndex = 0;
wb1.Save("d:\\test\\output_firstsecond.xls", FileFormatType.Default);

Thank you.

Hey Amjad, thanks for the reply.. it worked fine for me..

In the previous version of aspose, i never got this problem.

I was getting this error after i installed the new latest version of aspose.

Anyhow thanks for helping me in resolving this issue..

Vijay

Hi Vijay,

Please try this fix.

I am a license aspose.cell customer. Which version of update that I can download or get for the obove fix. I am using the aspose.cell version 4.1.1.8.

Thanks,
Michael

Hi,

Yes, please try the above fix which Warren attached in this thread.

Thank you.

Due to the versioning and licensing issue, it will only work if you can get me the fix for 4.1.1.8 instead of a 4.4.0.2. Please advice.

Thanks,
Michael