Worksheet.Copy not copying all forumulas


#1

I am having a problem with not all cell formulas copying to a new worksheet.

The command I am issueing is: newWorkSheet.Copy(wstemplate);

In column E3 I have this formula ="For Date Range " & G3 & " to " & H3

In column E4 I have this formula ="PromoID:" & G4

When I have immedately after issueing this command, E3 copies correctly but E4 is blank.

Aspose.Cells.Dll Version 4.0.2.0


#2

Hi,

Thanks for considering Aspose.

Could you please post your sample code and template file here, so that we may find out the problem.

Regards

Amjad Sahi

Aspose Nanjing Team


#3

Here is the code

using System;
using System.Collections.Generic;
using System.Text;
using Aspose.Cells;

namespace AsposeCopyError
{
class Program
{
static void Main(string[] args)
{
Workbook excelWorkbook1 = new Workbook();
Workbook excelWorkbook2 = new Workbook();
excelWorkbook1.Open(@“C:\Template.xlt”);
Worksheet wsTemplate = excelWorkbook1.Worksheets[0];
Worksheet wsFinal = excelWorkbook2.Worksheets[0];
wsFinal.Copy(wsTemplate);
excelWorkbook2.Save(@“C:\Final.xls”, FileFormatType.Default);
}
}
}

I send an Email with a template sample.
You can quickly create this template yourself by putting these forumlas into the E3-E5 cells of the worksheet.

="For Date Range " & G3 & " to " & H3
=“PromoID:” & G4
=“Acct Types:” & G5


#4

Please try this attached v4.0.2.6 and my template file. I used the following code and it worked fine:

Workbook wb1 = new Workbook();
wb1.Open("d:\\test\\book1.xls");
Workbook wb2 = new Workbook();
wb2.Worksheets[0].Copy(wb1.Worksheets[0]);
wb2.Save("d:\\test\\abc.xls");