資料匯出至 Excel 出問題求救!!! |
尚未結案
|
chener
一般會員 發表:3 回覆:2 積分:1 註冊:2003-02-21 發送簡訊給我 |
以下是我的匯出程式,但是在 sheet.OlePropertyGet("Cells",i,j+1).OlePropertySet("Value",tmpstr); 這一行執行時會出現下列訊息: " Project filename.exe raised exception class EOleSysError with 錯誤的變數類型. 請教高手幫忙解決,我的工作環境是 Windows 2000 & BCB6.0 Thanks... void __fastcall TForm1::ExcelFiles1Click(TObject *Sender)
{
Variant ex;
Variant wb;
Variant sheet;
AnsiString allfilename,tmpstr;
AnsiString SQLText;
int i,j; ex=Variant::CreateObject ("Excel.Application");
wb=ex.OlePropertyGet("ActiveWorkBook");
ex.OlePropertyGet("workbooks").OleFunction("Add");
sheet=ex.OlePropertyGet("ActiveSheet"); if (SQLSearch=="")
{
SQLText="select * from stock_control order by ProdID"; }
else
{ SQLText=SQLSearch + "order by ProdID"; } ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add(SQLText);
ADOQuery1->Open(); i=1; while (!ADOQuery1->Eof)
{
for (j=0;j
|
erosme
初階會員 發表:5 回覆:44 積分:29 註冊:2002-12-23 發送簡訊給我 |
|
chener
一般會員 發表:3 回覆:2 積分:1 註冊:2003-02-21 發送簡訊給我 |
|
jonno
一般會員 發表:0 回覆:1 積分:0 註冊:2002-09-13 發送簡訊給我 |
|
foxrabbit
一般會員 發表:11 回覆:16 積分:5 註冊:2003-11-10 發送簡訊給我 |
http://delphi.ktop.com.tw/topic.php?topic_id=40909
這裡有個範例你可以參考看看.... 或者 可以參考一下面這行指令的方式去做做看可不可以
Workbook.OleFunction("SaveAs", StringToOleStr(Edit1->Text.c_str()));
or
Cell=Worksheet.OlePropertyGet("Cells",16,j);
Cell.OlePropertySet("Value",StringToOleStr(ADOQuery1->Fields->Fields[8]->AsString));
|
ppippenkimo
一般會員 發表:7 回覆:17 積分:4 註冊:2003-11-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |