public void Main_start(string FileFullPath, string SavePath, string SaveFileName) { string savePath = Path.Combine(SavePath, SaveFileName); string[,] OriData = ReadExcelData(FileFullPath, out string[,] AllDatas, out string SheetName); if (null == OriData) { return; } EXCEL excel = new EXCEL(savePath); excel.Save(SheetName, 1, 1, CombineArray(this.Title1, AllDatas)); for (int i = 0; i < OriData.GetLength(0); i++) { Main_TWD97toTWD67(ref OriData, i); } string[,] res_1 = CombineArray(CombineArray(this.newTitle, this.Title2), OriData); string[,] res_2 = CombineArray(this.ResultTopTitle, res_1); string[,] res_3 = CombineArray(res_2, this.ResultBtnTitle); //excel.Save("TWD97轉TWD67", 1, 1, CombineArray(CombineArray(this.newTitle, this.Title2), OriData)); excel.Save_ChangeFormat("TWD97轉TWD67", 1, 1, res_3); excel.close(); }
private string[,] ReadExcelData(string path, out string[,] data, out string sheetName) { EXCEL excel = new EXCEL(path); data = excel.GetDataBySheetNumber(2, 1, 1); sheetName = excel.sheets[0]; excel.close(); // foreach (string item in excel.sheets) if (sheetName.Count() > 1 && item.Contains("TWD97轉TWD67")) return null; string[,] resData = new string[data.GetLength(0), 9]; for (int i = 0; i < resData.GetLength(0); i++) { resData[i, 0] = data[i, 1]; resData[i, 1] = data[i, 5]; resData[i, 2] = data[i, 6]; resData[i, 3] = data[i, 7]; resData[i, 4] = data[i, 8]; } return(resData); }