1
我使用此代碼導出HTML中的表格以便通過ActiveX複製和粘貼實現Excel。如何通過ActiveX設置Excel列格式從IE
我需要將所有在列B中設置爲文本格式,因爲在導出excel時將內容作爲第一個字符包含0。我嘗試我objWorksheet.Range("B:B").NumberFormat = "@";
線objWorksheet.columns.autofit;
之前,但它不能正常工作00001顯示爲1
var wshShell = new ActiveXObject("WScript.Shell");
var userProfile = wshShell.ExpandEnvironmentStrings("%USERPROFILE%\\Desktop\\xx.xls");
var thisTable = document.getElementById("mytable").innerHTML;
window.clipboardData.setData("Text", thisTable);
var objExcel = new ActiveXObject ("Excel.Application");
//objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add();
objWorkSheet = objWorkbook.WorkSheets(2);
objWorkSheet.Select;
objWorkSheet.Delete;
objWorkSheet = objWorkbook.WorkSheets(2);
objWorkSheet.Select;
objWorkSheet.Delete;
var objWorksheet = objWorkbook.Worksheets(1);
objWorkbook.Worksheets(1).Activate;
objWorksheet.name = "xxxxx";
objWorksheet.Paste;
objWorksheet.columns.autofit;