<mce:script language="javascript" type="text/javascript"><!--
function readExcel() {
var excelApp;
var excelWorkBook;
var excelSheet;
try{
excelApp = new ActiveXObject("Excel.Application");
excelWorkBook = excelApp.Workbooks.open("C:\\XXX.xls");
excelSheet = oWB.ActiveSheet; //WorkSheets("sheet1")
excelSheet.Cells(6,2).value;//cell的值
excelSheet.usedrange.rows.count;//使用的行数
excelWorkBook.Worksheets.count;//得到sheet的个数
excelSheet=null;
excelWorkBook.close();
excelApp.Application.Quit();
excelApp=null;
}catch(e){
if(excelSheet !=null || excelSheet!=undefined){
excelSheet =nul;
}
if(excelWorkBook != null || excelWorkBook!=undefined){
excelWorkBook.close();
}
if(excelApp != null || excelApp!=undefined){
excelApp.Application.Quit();
excelApp=null;
}
}
// --></mce:script>
如果是在网页上打开EXCEL 文件,那么在关闭的时候,进程里还有EXCEL.EXE,所以必须关闭后,刷新本页面!
js读取 EXCEL 文件
最新推荐文章于 2023-10-11 21:42:44 发布
本文介绍了一种使用VBA脚本从指定路径的Excel文件中读取数据的方法,并展示了如何获取单元格值、已用行数及工作表数量等关键信息。
837

被折叠的 条评论
为什么被折叠?



