public static CreateExcelTest GetCreateExcelTest() { if (createExcel == null) { return(createExcel = new CreateExcelTest()); } return(createExcel); }
private void OpenExcel() { string FilePath = @"C:\Users\14439\Desktop\yingpanhao\钻屑法模板.xlsx"; workBook = File.Exists(FilePath) ? new Workbook(FilePath) : new Workbook(); workSheet = workBook.Worksheets[0]; workBook_excel = CreateExcelTest.GetCreateExcelTest().GetWorkBookExcel(); workSheet_excel = workBook_excel.Worksheets[0]; //将模板拷贝到报表excel workSheet_excel.Copy(workSheet); workBook_excel.Save(excelFilePath, SaveFormat.Xlsx); }
//打开报表模板sheet2 private void OpenExcel() { string FilePath = @"C:\Users\14439\Desktop\yingpanhao\微震模板.xlsx"; workBook = File.Exists(FilePath) ? new Workbook(FilePath) : new Workbook(); workSheet = workBook.Worksheets[0]; workBook_excel = CreateExcelTest.GetCreateExcelTest().GetWorkBookExcel(); if (workBook_excel.Worksheets["Sheet2"] != null) { workSheet_excel = workBook_excel.Worksheets["Sheet2"]; } else { workBook_excel.Worksheets.Add("Sheet2"); workSheet_excel = workBook_excel.Worksheets["Sheet2"]; } workSheet_excel.Copy(workSheet); workBook_excel.Save(excelFilePath, SaveFormat.Xlsx); }