原創(chuàng)|使用教程|編輯:黃竹雯|2017-05-11 11:07:47.000|閱讀 1224 次
概述:使用Edraw office viewer component,vb開發(fā)人員可以輕松地將一個(gè)現(xiàn)有的Excel電子表格嵌入到表單中,然后進(jìn)行自動(dòng)化。在加載表單時(shí),開發(fā)人員可以使用Open方法從硬盤驅(qū)動(dòng)器或服務(wù)器中加載* .xls、* .xlsx、* .xslm或* .cvs文件,并在窗口的某個(gè)區(qū)域中打開。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Private Sub Form_Load() EDOffice1.OpenFileDialog'EDOffice1.OpenWord “d:\ test.xlsx” 'EDOffice1.Open“d:\ test.xls”,“Excel.Application” End Sub |
Private Sub EDOffice_DocumentOpened() EDOffice1.ProtectDoc 1'XlProtectTypeNormal End Sub |
bool ExcelAddWorkSheet(long Index); bool ExcelDeleteWorkSheet(long Index); bool ExcelActivateWorkSheet(long Index); 長(zhǎng)ExcelGetWorkSheetCount(); bool ExcelSetCellValue(long Column,long Row,BSTR Value); BSTR ExcelGetCellValue(長(zhǎng)列,長(zhǎng)行); 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); |
Private Sub Command1_Click()
Dim oXL As Excel.Application
Set oXL = EDOffice1.GetApplication() Dim oWB As Excel.Workbook Set oWB = EDOffice1.ActiveDocument() Dim oSheet As Excel.Worksheet Dim oRng As Excel.Range Set oSheet = oWB.ActiveSheet oSheet.Cells(1, 1).Value = "First Name" oSheet.Cells(1, 2).Value = "Last Name" oSheet.Cells(1, 3).Value = "Full Name" oSheet.Cells(1, 4).Value = "Salary" ' Format A1:D1 as bold, vertical alignment = center. With oSheet.Range("A1", "D1") .Font.Bold = True .VerticalAlignment = xlVAlignCenter End With ' Create an array to set multiple values at once. Dim saNames(5, 2) As String saNames(0, 0) = "John" saNames(0, 1) = "Smith" saNames(1, 0) = "Tom" saNames(1, 1) = "Brown" saNames(2, 0) = "Sue" saNames(2, 1) = "Thomas" saNames(3, 0) = "Jane" saNames(3, 1) = "Jones" saNames(4, 0) = "Adam" saNames(4, 1) = "Johnson" ' Fill A2:B6 with an array of values (First and Last Names). oSheet.Range("A2", "B6").Value = saNames ' Fill C2:C6 with a relative formula (=A2 & " " & B2). Set oRng = oSheet.Range("C2", "C6") oRng.Formula = "=A2 & "" "" & B2" ' Fill D2:D6 with a formula(=RAND()*100000) and apply format. Set oRng = oSheet.Range("D2", "D6") oRng.Formula = "=RAND()*100000" oRng.NumberFormat = "$0.00" ' AutoFit columns A:D. Set oRng = oSheet.Range("A1", "D1") oRng.EntireColumn.AutoFit oXL.UserControl = True End Sub |
試用、下載、了解更多產(chǎn)品信息請(qǐng)點(diǎn)擊""
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn