BCB抓到Excel內容卻不能干運算?


BCB抓到Excel內容卻不能作運算??
//需使用OpenDialog1,  Memo1

   Form1->Hide();


   AnsiString filepath;


  if(OpenDialog1->Execute())                        //若開啟檔案成功

   {

       filepath=  OpenDialog1->FileName.c_str();      //把檔案路徑儲存 filepath

   }



//declaration of variables of type variant    宣告變數

      Variant XL,v0,v1,vcell;

      int i,j,count=StrToInt(InputBox("Excel","請輸入資料總筆數:",""));



//a string where you will temporarily put the content of a single Cell     暫存Excel單格資料

     AnsiString tmp,x[1000],y[1000],z[1000 ];


//create an object which is an excel application and store it to XL   

     XL=Variant::CreateObject("excel.application");


//Set the Excel Application as invisible once you have opened it     Excel應用程序設置為不可見

     XL.OlePropertySet("Visible",false);


//Get the workbooks while has a path stored in “file” variable and open it.


     XL.OlePropertyGet("Workbooks").OleProcedure("Open", filepath.c_str() );


//Get the Sheet which has a title “Sheet1〃


     v0=XL.OlePropertyGet("Sheets","Sheet1");


//Get the Cells of that particular Sheet.   獲取Excel單格資料表。


     v1=v0.OlePropertyGet("Cells");




        for(i=10;i<=count;i++)

            {

                    vcell=v1.OlePropertyGet("Item",i,2);//決定要讀取的位置 at row i and column j

                    x[i]=vcell.OlePropertyGet("Value");


                    vcell=v1.OlePropertyGet("Item",i,3);

                    y[i]=vcell.OlePropertyGet("Value");


                    vcell=v1.OlePropertyGet("Item",i,4);

                    z[i]=vcell.OlePropertyGet("Value");

                    //重複 上兩行決定要讀的數字

                    //印出


            }

        XL.OleProcedure("Quit");   //關閉檔案

        XL=Unassigned;


       float VectorN[3],VectorU[3],Vector_V[3],x0,y0,z0;   //設向量N,U,V 圓心x0,y0,z0

相关链接

基本概念 C++/VC 程序开发

rained 10 years, 7 months ago

Your Answer