EXCELファイルのjsコード1/2ページを読み取ることができます
8757 ワード
トップページには中国語の説明例がありますが、次の例では多くの人がテストすることができます.
<!--
<br>function readExcel() {
<br>var excelApp;
<br>var excelWorkBook;
<br>var excelSheet;
<br>try{
<br>excelApp = new ActiveXObject("Excel.Application");
<br>excelWorkBook = excelApp.Workbooks.open("C:\\XXX.xls");
<br>excelSheet = oWB.ActiveSheet; //WorkSheets("sheet1")
<br>excelSheet.Cells(6,2).value;//cell
<br>excelSheet.usedrange.rows.count;//
<br>excelWorkBook.Worksheets.count;// sheet
<br>excelSheet=null;
<br>excelWorkBook.close();
<br>excelApp.Application.Quit();
<br>excelApp=null;
<br>}catch(e){
<br>if(excelSheet !=null || excelSheet!=undefined){
<br>excelSheet =nul;
<br>}
<br>if(excelWorkBook != null || excelWorkBook!=undefined){
<br>excelWorkBook.close();
<br>}
<br>if(excelApp != null || excelApp!=undefined){
<br>excelApp.Application.Quit();
<br>excelApp=null;
<br>}
<br>}
<br>
<br>// -->
EXCEL , , EXCEL.EXE, , !
<br>function ReadExcel()
<br>{
<br>var tempStr = "";
<br>var filePath= document.all.upfile.value;
<br>var oXL = new ActiveXObject("Excel.application");
<br>var oWB = oXL.Workbooks.open(filePath);
<br>oWB.worksheets(1).select();
<br>var oSheet = oWB.ActiveSheet;
<br>try{
<br>for(var i=2;i<46;i++)
<br>{
<br>if(oSheet.Cells(i,2).value =="null" || oSheet.Cells(i,3).value =="null" )
<br>break;
<br>var a = oSheet.Cells(i,2).value.toString()=="undefined"?"":oSheet.Cells(i,2).value;
<br>tempStr+=(" "+oSheet.Cells(i,2).value+
<br>" "+oSheet.Cells(i,3).value+
<br>" "+oSheet.Cells(i,4).value+
<br>" "+oSheet.Cells(i,5).value+
<br>" "+oSheet.Cells(i,6).value+"
");
<br>}
<br>}catch(e)
<br>{
<br>document.all.txtArea.value = tempStr;
<br>}
<br>document.all.txtArea.value = tempStr;
<br>oXL.Quit();
<br>CollectGarbage();
<br>}
<br>