Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am using export to excel functionality in Shrepoint using JavaScript. But Auto Fit is not working for the same.
Is anyone is having anyidea.
Below is the code snippet.
JavaScript
function ExportHTMLTableToExcel() { 
    //var thisTable = document.getElementById("ExcelData").innerHTML; 
    var thisTable = $("div.ExcelData").html(); 
    window.clipboardData.setData("Text", thisTable); 
    var objExcel = new ActiveXObject("Excel.Application"); 
    objExcel.visible = true; 
    var objWorkbook = objExcel.Workbooks.Add; 
    var objWorksheet = objWorkbook.Worksheets(1); 
    objWorksheet.Paste; 
    ExcelSheet.Range("A1", "B1", "C1").EntireColumn.AutoFit(); 
    objWorksheet.Range("A1", "Z1").EntireColumn.AutoFit(); 
    
    objWorksheet.Range("C1", "C1").ColumnWidth = 2000; 
}

Thanks in Advance
Posted
Updated 23-Mar-15 4:53am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900