///========================================== /// main static void Main(string[] args) { // 入力エクセルファイル s_srcFile = "src.xlsm"; // 出力エクセルファイル s_destFile = "dest.xlsx"; Const.ExtensionName = Utility.GetFileNameExtension(s_srcFile); // extension 置き換え SetupCmdArgs(ref s_srcFile, ref s_destFile); ExcelApp.GetInstance(); // instance create ExcelData ebdata = new ExcelData(); ExcelData ecdata = new ExcelData(); LoadFile( s_srcFile , s_destFile , ref ebdata , ref ecdata ); log("マージ中 ..."); MergeSheet(ebdata, ecdata); log("マージ終了"); TermLoadFile(ebdata, ecdata); ExcelApp.Release(); Utility.ReplaceFileNames(replacedir, ExcelABMergeTool.Const.MergeName, Const.ExtensionName); log("完了! "); }
public static ExcelApp GetInstance() { if (instance == null) { instance = new ExcelApp(); } return(instance); }
/// <summary> /// Excelデータ作成 /// </summary> /// <param name="fileName"></param> /// <returns></returns> static ExcelData CreateExcel(string fileName) { ExcelData ed = new ExcelData(); log("'" + fileName + "'を作成します。"); ed.filename = fileName; ed.workbook = ExcelApp.GetInstance().sWorkBook.Add(); // ed.workbook.SaveAs(fileName); // 後でセーブ // ed.workbook.Worksheets.Add(Type.Missing); ed.sheets = ed.workbook.Sheets; // ed.worksheet = ed.sheets[1]; ed.saveflag = true; return(ed); }
public bool saveflag; // fix warning /// <summary> /// 初期化 /// </summary> /// <param name="filename">エクセルファイル名</param> public void init(string filename) { this.filename = filename; workbook = ExcelApp.GetInstance().sWorkBook.Open(filename); sheets = workbook.Sheets; int sheetNum = sheets.Count; foreach (Excel.Worksheet ws in sheets) { worksheet = ws; break; #if false WorkSheetDebug(ws); #endif } }
public static void Release() { instance.TermExcelApp(); instance = null; }