function printExc(tableId) {
try {
var elTable = document.getElementById(tableId);
var oRangeRef = document.body.createTextRange();
oRangeRef.moveToElementText(elTable);
oRangeRef.execCommand("Copy");
var oXL = new ActiveXObject("Excel.Application");
var oWB = oXL.Workbooks.Add;
var oSheet = oWB.ActiveSheet;
oSheet.Paste();
//oSheet.Cells.NumberFormatLocal = "@"; //格式化数字时使用
//oSheet.Columns("D:D").Select;
//oXL.Selection.ColumnWidth = 10;
oXL.Selection.Columns.AutoFit; //列宽自动适应
oXL.Selection.rowHeight = 22; //行高
oXL.Visible = true;
oSheet = null;
oWB = null;
appExcel = null;
}
catch (e) {
alert(e.description);
}
}
页面通过Js导出excel.页面table里显示的格式都是正确的,但是为什么导成excel之后格式就乱了??
ps 是不是跟我用jquery合并的部分单元格有关系??急!!