原創(chuàng)|其它|編輯:郝浩|2012-08-28 01:18:48.000|閱讀 1089 次
概述:本文介紹了Edraw Office Viewer控件的一個(gè)操作實(shí)例,如何用VB 6添加Excel文檔。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
啟動(dòng)Visual Basic,創(chuàng)造出一個(gè)新的標(biāo)準(zhǔn)項(xiàng)目默認(rèn)為Form1。
在工具箱的面板中,右鍵單擊空白區(qū)域。然后單擊組件……
在彈出的對(duì)話框中,選中Edraw Office Viewer Component組件。
點(diǎn)擊OK按鈕。
工具欄窗口中將會(huì)添加Office Viewer Component組件。
切換到VB 6窗體,添加組件。
組件包含了大量的方法、事件和屬性用于自定義Excel窗口。
開發(fā)人員可以使用以下代碼在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工作表,開發(fā)人員需要在DocumentOpened事件中添加以下代碼。
Private Sub EDOffice_DocumentOpened()
EDOffice1.ProtectDoc 1 ' XlProtectTypeNormal
End Sub
在創(chuàng)建或修改excel數(shù)據(jù)是可以用到一些excel自動(dòng)化方法。
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);
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:翻譯