原創|其它|編輯:郝浩|2012-08-28 01:18:48.000|閱讀 1089 次
概述:本文介紹了Edraw Office Viewer控件的一個操作實例,如何用VB 6添加Excel文檔。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
啟動Visual Basic,創造出一個新的標準項目默認為Form1。
在工具箱的面板中,右鍵單擊空白區域。然后單擊組件……
在彈出的對話框中,選中Edraw Office Viewer Component組件。
點擊OK按鈕。
工具欄窗口中將會添加Office Viewer Component組件。
切換到VB 6窗體,添加組件。
組件包含了大量的方法、事件和屬性用于自定義Excel窗口。
開發人員可以使用以下代碼在Form_Load Event中打開excel文件。
Private Sub Form_Load()
EDOffice1.OpenFileDialog
'EDOffice1.OpenWord "d:\test.xlsx"
'EDOffice1.Open "d:\test.xls", "Excel.Application"
End Sub
為了不讓終端用戶修改Excel工作表,開發人員需要在DocumentOpened事件中添加以下代碼。
Private Sub EDOffice_DocumentOpened()
EDOffice1.ProtectDoc 1 ' XlProtectTypeNormal
End Sub
在創建或修改excel數據是可以用到一些excel自動化方法。
bool ExcelAddWorkSheet(long Index);
bool ExcelDeleteWorkSheet(long Index);
bool ExcelActivateWorkSheet(long Index);
long ExcelGetWorkSheetCount();
bool ExcelSetCellValue(long Column, long Row, BSTR Value);
BSTR ExcelGetCellValue(long Column, long Row);
bool ExcelSetRowHeight(long Row, double Height);
bool ExcelSetColumnWidth(long Column, double Width);
afx_msg bool ExcelDeleteRow(long Row);
bool ExcelDeleteColumn(long Column);
bool ExcelInsertRow(long Row);
bool ExcelInsertColumn(long Column);
bool ExcelInsertPageBreakInRow(long Row);
bool ExcelInsertPageBreakInColumn(long Column);
bool ExcelCopyToClipboard();
bool ExcelPasteStringToWorksheet(BSTR bstText);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:翻譯