Hi,
Well, after some evaluation, I think there is no direct way to do it in MS Excel either. I think you may try to utilize some workaround (using/adding referenced formulas in the destination range) to do your task. See the sample code below for your help.
Sample code:
E.g
// Create a Workbook object
//Open an existing file.
Workbook workbook = new Workbook("e:\\test\\book1.xls");
// Get the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Add a worksheet to the workbook.
int index = workbook.Worksheets.Add();
Worksheet mysheet = workbook.Worksheets[index];
//Name the sheet.
mysheet.Name = "MySheet";
// Create a named range of the Cells
Range range1 = worksheet.Cells.CreateRange("A1", "B2");
//Create another range of cells in the new sheet.
Range range2 = mysheet.Cells.CreateRange("A1", "B2");
// Copy the data with formatting of the range to the second range.
range2.Copy(range1);
//Apply formulas to each cell in cell in the destination range in
//accordance with cells values in the source range cells
for (int i = 0; i < range2.RowCount; i++)
{
for (int j = 0; j < range2.ColumnCount; j++)
{
range2[i, j].Formula = "=" + range1.Worksheet.Name +"!" + range1[i, j].Name;
}
}
workbook.Save("e:\\test2\\output.xls");
Amjad Sahi
Support Developer,
Aspose Sialkot Team
Contact Us