
Sub test()
Set oExcel = GetObject(, "ExcelApplication")
Set oWb = oExcelWorkbooksOpen("D:\testxls") '写你自己的Excel路径
MsgBox oWbSheets("Sheet1")Range("C5") '取"Sheet1"工作表C5单元格的值
oExcelQuit '退出Excel
End Sub
按 Alt+F11 打开VBE窗口,通过菜单选择“插入”-“模块”,输入以上代码。
这里采用的是后置绑定方法,无需事先加载Excel对象引用库。
如果在此过程中希望Excel窗口不可见,可在调用open方法打开Excel之前设置visible属性:
oExcelVisible = False
用 php Win32 OLE
##Using OLE;
read('Book1xls');
// print number of rows, columns and sheets
echo "Number of sheets: " sizeof($excel->sheets) "\n";
for ($x=0; $xsheets); $x++) {
echo "Number of rows in sheet " ($x+1) ": " $excel->sheets[$x]["numRows"] "\n";
echo "Number of columns in sheet " ($x+1) ": " $excel->sheets[$x]["numCols"] "\n";
以上就是关于如何在excel中编写宏读取数据库全部的内容,包括:如何在excel中编写宏读取数据库、php读取excel并写入到数据库、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)