How to update Excel file from Asp?

Results 1 to 2 of 2

Thread: How to update Excel file from Asp?

  1. #1
    Join Date
    Dec 1969

    Default How to update Excel file from Asp?

    I need to go through the loop of all the rows of the existing excel file and update one cell in each row using asp. Please help. Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: How to update Excel file from Asp?

    You may be able to use the Office web components to do this, but if you want to use the jet driver you can try this:<BR><BR>var cn = Server.CreateObject("ADODB.Connection");<BR>cn.ope n("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.mapPath("fileName.xls") + ";Extended Properties=Excel 8.0;");<BR>cn.cursorLocation = 3;<BR><BR>// Now here you can try an update statement, such as<BR>// cn.Execute("UPDATE [SpreadSheetName$] SET fieldName = &#039;NewVal&#039;");<BR>// but I cound not get the update statement to work<BR>// with the version of the driver I was using<BR>var rs = Server.CreateObject("ADODB.Recordset");<BR> ("[SpreadSheetName$]", cn, 3, 3);<BR><BR>for (i = 0; i &#060; rs.recordCount; i++) {<BR> rs("fieldName") = "NewVal";<BR> rs.moveNext();<BR>}<BR>rs.update();<BR><BR>rs.clos e();<BR>rs = null;<BR>cn.close();<BR>cn = null;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts