請問存成EXCEL |
尚未結案
|
starhua628
一般會員 發表:16 回覆:9 積分:5 註冊:2005-03-19 發送簡訊給我 |
請問我用BCB輸出EXCEL檔後,當我開起來該EXCEL檔時會發生下面圖的情況,感覺像是程式沒有完全離開似的,請教各位是發生了什麼樣的錯誤嗎...多謝指導了^^
//----建立Excel Variant ExcelApp, ExcelBooks, ExcelBook; try { ExcelApp=Variant::CreateObject("Excel.Application"); } catch(Exception &e) { ShowMessage(e.Message); } if(ExcelApp.IsEmpty()) { return; } //ExcelApp.OlePropertySet("Visible", true); // 把這行刪掉, Excel 執行畫面就不會出現 ExcelBooks=ExcelApp.OlePropertyGet("Workbooks"); try { ExcelBook=ExcelBooks.OleFunction("Add"); } catch(Exception &e) { ShowMessage(e.Message); } if(ExcelBook.IsEmpty()) { return; } //----建立新的EXCEL檔 AnsiString szXlsFile; //AnsiString szXlsFile=ExtractFilePath(Application->ExeName)+"test.xls"; if(SaveDialog1->Execute()) { szXlsFile=SaveDialog1->FileName.c_str(); ExcelBook.OleFunction("SaveAs", StringToOleStr(szXlsFile)); ExcelBook.OleFunction("Close"); ExcelApp.OleFunction("Quit"); } //----寫入Excel Variant Ex,Wb,Sh; Ex=Variant::CreateObject("Excel.Application"); Ex.OlePropertyGet("WorkBooks").OleProcedure("Open",StringToOleStr(szXlsFile)); Wb=Ex.OlePropertyGet("ActiveWorkBook"); Sh=Wb.OlePropertyGet("ActiveSheet"); Sh.OlePropertyGet("Cells",1,1).OlePropertySet("Value","連續白色"); Sh.OlePropertyGet("Cells",1,2).OlePropertySet("Value","連續黑色"); |
HM
初階會員 發表:21 回覆:32 積分:25 註冊:2004-11-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |