Skip to Content
0
Sep 27, 2012 at 09:42 AM

Excel data upload in WEBUI

266 Views

Hi all,

I am uploading the excel sheet in WEBUI.

For that I am using Java script to pick the file as well as upload the excel data. Here Upload_file is also executing , It is taking the Alert message also what file we are trying to load .

After that Excel object was not getting generating . I did BOLD that code where I am getting the problem. The Control is not triggering the Second Alert " This file is mine" means above code is not working . Already I have checked all the active controls. Do I need to active still anything .

When I click on Upload button , After Alert message .. Excel was not generating .. Please help me in this What i need to do.

Please find the code. This code I have copied from blog excel upload in WEBUI.

regards,

Ajay

<script language="javascript" type="text/javascript">

function upload_file( ){

var iRow="1",

jCol="1",

ActiveRows="0",

fileName="",

sValue=" ";

fileName=document.getElementById("<%= controller->component_id %>_fileUpDown").value;

if ( fileName == "" ) {

alert("Upload." + "\n" + " " + "\n" + "Please choose an Excel file as source.");

return;

}

if ( fileName != "") {

alert("Upload." + "\n" + " " + "\n" + "This file is to be uploaded:" + "\n" + fileName);

Excel = new ActiveXObject("Excel.Application");

Book = Excel.Workbooks.Open( fileName );

alert("Upload." + "\n" + " " + "\n" + "This file is mine:" + "\n" + fileName);

ActiveRows = Book.Worksheets("Sheet1").Range("A1.IV64000").CurrentRegion.Rows.Count;

for (iRow=1; iRow<=ActiveRows; iRow++) {

for (jCol=1; jCol<4; jCol++) {

cData = Book.Worksheets("Sheet1").Cells(iRow,jCol).value;

sValue = sValue.concat(cData,"\n");

}

}

document.getElementById("<%= controller->component_id %>_Excel_Data").value = sValue;

Excel.Workbooks.Close;

return nameUpload();

}

}

</script>