EasyXLS
http://forum.easyxls.com/

Copying Sheets
http://forum.easyxls.com/viewtopic.php?f=5&t=52
Page 1 of 1

Author:  teniel [ Sun Jul 08, 2007 11:34 pm ]
Post subject:  Copying Sheets

I have a template with two sheets. I would like to copy the second sheet five times.

Code:
ExcelDocument xls = new ExcelDocument();
         
xls.easy_LoadTemplateFile("C:\\template.xls");
ExcelWorksheet xlsSheet = (ExcelWorksheet)xls.easy_getSheetAt(1);   

for (int j=0; j<5 ; j++) {
     xlsSheet.setSheetName("" + j);
     xls.easy_insertWorksheet(j+1, xlsSheet);
}

         


This gives me an error of
Quote:
A sheet having this title already exists in this document!


I understand why this is, but I don't know how to solve it.

Author:  daniela [ Mon Jul 09, 2007 4:27 am ]
Post subject: 

My suggestion is to create all 5 sheets into your template and not to try to use the same sheet.

If you are interesting only on using cell values and cell formatting from that sheet, you can use the following trick, but you will still have problems if you will try to add more data:

for (int j=0; j<5 ; j++) {
ExcelWorksheet xlsNewSheet = new ExcelWorksheet("" + j);
xlsNewSheet.easy_setExcelTable(xlsSheet.easy_getExcelTable());
xls.easy_insertWorksheet(j+1, xlsNewSheet);
}

Author:  amit.nayar [ Thu Jul 19, 2007 12:47 pm ]
Post subject: 

Is there ANY other better way to copy sheets and preserve things such as charts on the sheet ? When I do this, the charts are gone.

Also, when I do this and make changes on the copied sheet, it changes to original sheet. So it looks like the Excel Table is like a shallow copy and changes to it on the new sheets actually change the original sheet.

We really need a sheet copy functionality like Excel does. Is this not in the plans for EasyXLS? It seems like a nice feature to have.

Author:  murali [ Tue Oct 16, 2007 6:32 am ]
Post subject:  Copying Worksheets to new excel sheet

Hi All,

I need to copy the worksheet from one excel sheet to another excel sheet,how will i do that.When i rightclick on worksheet and select move or copy option it will not show new excel sheet.can anybody help me in this regard.

Would greatly appreciate ur help.

Regards,
SMR

Page 1 of 1 All times are UTC - 4 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/