我正在使用Javascript函数将表格内容导出到Excel电子表格。但是,包含表中的所有数据,我有一些图像和超链接需要在函数中删除。我使用标记来标记tablespan。这是我的功能:
function exportTimesheetToExcel(techs_name,tablespan){
var exportAlert = document.getElementById(tablespan);
if(exportAlert == null){
alert("No report to be exported.");
}
else{
var excelExport1 = document.getElementById(techs_name).innerHTML;
var excelExport2 = document.getElementById(tablespan).innerHTML;
excelExport="Timesheet summary for "+" " + excelExport1+excelExport2;
window.clipboardData.setData("text", excelExport);
var objExcel = new ActiveXObject ("Excel.Application");
objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
objWorksheet.UsedRange.Borders.LineStyle = 1;
//objWorksheet.UsedRange.Style.HorizontalAlignment="Left";
var countRow=objWorksheet.UsedRange.Rows.count;
//alert(objWorksheet.Cells(10,1).Value);
for(var i=1; i<=countRow ; i++){
var rowVal=objWorksheet.Cells(i,1).Value;
if((rowVal=='Comment')|| (rowVal=='Verification Comments')){
objWorksheet.Cells(i+1,1).Rowheight="70";
}
}
}
我试图详细解释这个问题。但是,请原谅我的无知。我是编程新手(我试图在线找到解决方案,但没有成功).. 提前谢谢!