10金币
本帖最后由 锦鲤本李 于 2024-9-3 16:32 编辑
复制粘贴区域数据后 单元格的计算式会变化,怎么解决
把sheet2中红框内的数据A3:A32(图1)复制到sheet1的指定位置(A45:A76)后,计算式发生变化(图2),但是粘贴到sheet1与sheet2同样的位置(A3:A32),计算式显示正确(图3)
图1
图2
图3
代码:
- SpreadsheetGear.IWorkbookSet excelApp = SpreadsheetGear.Factory.GetWorkbookSet();
- SpreadsheetGear.IWorkbook workBook = null;
- SpreadsheetGear.IWorksheet sheet = null;
- SpreadsheetGear.IWorksheet sheet2 = null;
- workBook = excelApp.Workbooks.Open(文件路径);
- int copyRowCount = Selp921922mSheet2PageCount * SHEET2_MAX_ROW_2;//复制的行数
- sheet2 = (SpreadsheetGear.IWorksheet)workBook.Sheets[1];
- string sCopyArea = "A3:" + "T" + copyRowCount;//复制区域
- SpreadsheetGear.IRange cells2 = sheet2.Cells;
- SpreadsheetGear.IRange rangeFrom = cells2[sCopyArea].EntireRow;
- string sPasteArea = "A" + SHEET1_MAX_ROW + ":T" + (SHEET1_MAX_ROW + copyRowCount).ToString();//粘贴区域
- sheet = (SpreadsheetGear.IWorksheet)workBook.Sheets[0];
- SpreadsheetGear.IRange cells = sheet.Cells;
- SpreadsheetGear.IRange rangeTo = cells[sPasteArea].EntireRow;
- rangeFrom.Copy(rangeTo, SpreadsheetGear.PasteType.All,
- SpreadsheetGear.PasteOperation.None, false, false);
复制代码
|
|