bcb挖礦app
A. 信鏈星球APP轉盤活動怎麼增加次數
假的啊,如果下載建議用360手機衛士查殺
B. 高手給看下 BCB報錯: [Linker Fatal Error] Fatal: Unable to open file 'SINGLEAPPINSTANCE.BPI'
編譯的時候找不到SINGLEAPPINSTANCE.BPI文件。
請將所有臨時文件都刪除掉,比如obj,或其他程序自動生成的文件,然後builder整個工程,重新生成。
C. 請問誰能提供 BCB(C++builder)直接操作Office Excel 1.基本操作 匯/出入 2.由程序控制Excel 欄位3.存成fil
參考資料:http://blog.csdn.net/zjt621/archive/2007/01/30/1498104.aspx
要在應用程序中控制Excel的運行,首先必須在編制自動化客戶程序時包含Comobj.hpp
#include "Comobj.hpp"
C++ Builder把Excel自動化對象的功能包裝在下面的四個Ole Object Class函數中,應用人員可以很方便地進行調用。
設置對象屬性:Variant OlePropertySet(屬性名,參數……);
獲得對象屬性:void OlePropertyGet(屬性名,參數……);
調用對象方法:1) Variant OleFunction(函數名,參數……);
2) void OleProcere(過程名,參數……);
在程序中可以用宏定義來節省時間:
#define PG OlePropertyGet
#define PS OlePropertySet
#define FN OleFunction
#define PR OleProcere
舉例:
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add")可寫為
ExcelApp.PG("workbooks").FN("Add")
C++ Builder中使用OLE控制Excel2000,必須掌握Excel2000的自動化對象及Microsoft Word Visual Basic幫助文件中的關於Excel的對象、方法和屬性。對象是一個Excel元素,屬性是對象的一個特性或操作的一個方面,方法是對象可以進行的動作。
首先定義以下幾個變數:
Variant ExcelApp,Workbook1,Sheet1,Range1;
1、Excel中常用的對象是:Application,Workbooks,Worksheets等。
(1)創建應用對象:如:
Variant ExcelApp;
ExcelApp=Variant::CreateObject ("Excel.Application");
或者
ExcelApp=CreateOleObject ("Excel.Application");
(2)創建工作簿對象:
Variant WorkBook1;
WorkBook1=ExcelApp.OlePropertyGet("ActiveWorkBook");
(3)創建工作表對象:
Variant Sheet1;
Sheet1=WorkBook1.OlePropertyGet("ActiveSheet");
(4)創建區域對象:
Variant Range;
Range=Sheet1.OlePropertyGet("Range","A1:A10");
2、常用的屬性操作:
(1)使Excel程序不可見
ExcelApp.OlePropertySet("Visible",(Variant)false);
(2)新建EXCEL文件:
(a):新建系統模板的工作簿
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add") //默認工作簿
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add",1) //單工作表
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add",2) //圖表
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add",3) //宏表
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add",4) //國際通用宏表
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add",5) //與默認的相同
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add",6) //工作簿且只有一個表
(b):新建自己創建的模板的工作簿
ExcelApp.OlePropertyGet("workbooks").OleFunction("Add","C:\\Templates\\result.xlt");
(3)打開工作簿:
ExcelApp.OlePropertyGet("workbooks").OleFunction("open","路徑名.xls")
(4)保存工作簿:
WorkBook1.OleFunction("Save"); //保存工作簿
WorkBook1.OleFunction("SaveAs","文件名"); //工作簿保存為,文件路徑注意用「\\」
(5)退出EXCEL:
ExcelApp.OleFunction ("Quit");
ExcelApp=Unassigned;
(6)操作工作表
(a)選擇選擇工作表中第一個工作表
Workbook1.OlePropertyGet("Sheets",1).OleProcere("Select");
Sheet1=Workbook1.OlePropertyGet("ActiveSheet");
(b)重命名工作表
Sheet1.OlePropertySet("Name","Sheet的新名字");
(c)當前工作簿中的工作表總數
int nSheetCount=Workbook1.OlePropertyGet("Sheets").OlePropertyGet("Count");
(7)操作行和列:
(a)獲取當前工作表中有多少行和多少列:
Sheet1.OlePropertyGet("UsedRange").OlePropertyGet("Columns").OlePropertyGet("Count"); //列數
Sheet1.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count"); //行數
(b)設置列寬
ExcelApp.OlePropertyGet("Columns",1).OlePropertySet("ColumnWidth",22);
(c)設置行高
ExcelApp.OlePropertyGet("Rows",2).OlePropertySet("RowHeight",25);
(d)在工作表最前面插入一行
Sheet1.OlePropertyGet("Rows",1).OleProcere("Insert");
(e)刪除一行
ExcelApp.OlePropertyGet("Rows",2).OleProcere("Delete"); //將第2行刪除
(7)操作單元格
(a):設置單元格字體
Sheet1.OlePropertyGet("Cells",1,1).OlePropertyGet("Font").OlePropertySet("Name","隸書"); //字體
Sheet1.OlePropertyGet("Cells",2,3).OlePropertyGet("Font").OlePropertySet("size",28); //大小
(b):設置所選區域字體
Range.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Size",28);
Range.OlePropertyGet("Cells").OlePropertyGet("Font").OlePropertySet("Color",RGB(0,0,255));
其中參數的設置:
Font Name : "隸書" //字體名稱
Size : 12 //字體大小
Color : RGB(*,*,*) //顏色
Underline : true/false //下劃線
Italic: true/false //斜體
(c)設置單元格格式為小數百分比
Sheet1.OlePropertyGet("Cells",1,1).OlePropertySet("NumberFormatLocal","0.00%");
(8)單元格的合並:
(a)Range=Sheet1.OlePropertyGet("Range", "A1:A2"); //A1和A2單元格合並
(b)String strRange="A"+IntToStr(j)+":"+"C"+IntToStr(j); //比如:A1:C5
Range1=Sheet1.OlePropertyGet("Range",strRange.c_str()); //可以用變數控制單元格合並
Range1.OleFunction("Merge",false);
(9)讀寫單元格:
(a):指定單元格賦值
String strValue="abcdefg";
Sheet1.OlePropertyGet("Cells",3,6).OlePropertySet("Value",strValue.c_str());
Sheet1.OlePropertyGet("Cells",j,1).OlePropertySet("Value","總記錄:"+String(j-6));
(b):所選區域單元格賦值
Range.OlePropertyGet("Cells").OlePropertySet("Value",10);
(c):所選區域行賦值
Range.OlePropertyGet("Rows",1).OlePropertySet("Value",1234);
(d):工作表列賦值
Sheet1.OlePropertyGet("Columns",1).OlePropertySet("Value",1234);
(c):讀取取值語句:
String strValue=Sheet1.OlePropertyGet("Cells",3,5).OlePropertyGet("Value");
(10)區域選擇:
Range1.OlePropertyGet("Cells").OleFunction("Select");
(11)窗口屬性:
(a)顯示屬性
ExcelApp.OlePropertySet("Windowstate",3); //最大化顯示
1---------xlNormal //正常顯示
2---------xlMinimized //最小化顯示
3---------xlMaximized //最大化顯示
(b)狀態欄屬性
ExcelApp.OlePropertySet("StatusBar","您好,請您稍等。正在查詢!");
ExcelApp.OlePropertySet("StatusBar", false); //還原成默認值
(c)標題屬性:
ExcelApp.OlePropertySet("Caption","查詢系統");
另外,為保證程序能正常運行,需要在程序中判斷目標機器是否安裝了Office;
try
{
ExcelApp=Variant::CreateObject ("Excel.Application");
}
catch(...)
{
ShowMessage("運行Excel出錯,請確認安裝了Office");
return;
}