public static bool splitTxt() { string today = DateTime.Now.ToString("MMdd"); int lastRow = 2; bool flag = false; if (allLinesText.Count == 0) { Console.WriteLine("TxtFile is empty"); } else { ExcelTool e1 = new ExcelTool(); e1.openExcel(@"C:\CRPADATA\U111705\downloadFile\全聯EDC異常.xlsx", "12010499"); e1.addSheet(today); e1.selectSheet(today); foreach (string line in allLinesText) { e1.setCellValue(line, lastRow, 2); lastRow = lastRow + 1; } e1.dataSplit(allLinesText.Count); for (int i = 2; i <= allLinesText.Count + 1; i++) { e1.setCellValue(DateTime.Now.ToString("MM月dd日"), i, 1); } e1.setExcelTitle(); e1.closeExcel(); flag = true; } return(flag); }
// 複製sheet,並將卡號與正負項金額資料撈出 public static void writeIntoExcel(string excelPwd, bool excelType) //true-> 開啟全聯異常帳 false -> 全聯異常帳-錢包 { int lastRow = 35; string currentDay = DateTime.Now.ToString("MMdd"); string year = (DateTime.Today.Year - 1911).ToString(); ExcelTool e1 = new ExcelTool(); if (excelType) { e1.openExcel(@"C:\CRPADATA\U111705\downloadFile\全聯異常帳" + year + currentDay.Substring(0, 2) + ".xlsx", excelPwd); } else { e1.openExcel(@"C:\CRPADATA\U111705\downloadFile\全聯異常帳" + year + currentDay.Substring(0, 2) + "-錢包.xlsx", excelPwd); } if (tempStructureList.Count > 0) { e1.selectSheet(currentDay); foreach (customers c in tempStructureList) { e1.setCellValue("'" + c.storeCaseNo, lastRow, 1); e1.setCellValue(c.storeName, lastRow, 2); e1.setCellValue(c.accountDate, lastRow, 3); e1.setCellValue("'" + c.cardNumber, lastRow, 4); e1.setCellValue(c.tradeCaseNo, lastRow, 5); e1.setCellValue(c.transationDate, lastRow, 6); e1.setCellValue(c.tradeMoney, lastRow, 7); e1.setCellValue("'" + c.approvalCaseNo, lastRow, 8); lastRow = lastRow + 1; } } tempStructureList.Clear(); e1.closeExcel(); }