|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Hi, guys.
This is my first time. Please be gentle. Nice to meet you guys. I am trying to export data from access database to excel spreadsheet. Please take a look at following code. code:-------------------------------------------------------------------------------- <HTML> <HEAD> </HEAD> <BODY LEFTMARGIN=0 MARGINWIDTH="0" MARGINHEIGHT="0"> <a href="pricelist.asp"><FONT FACE=Arial,Helvetica SIZE=2><B>Price List</B></FONT></a> </BODY> </HTML> -------------------------------------------------------------------------------- When I click link Price List, I go to following page. code:-------------------------------------------------------------------------------- <%@ Language="VBScript" %> <% Option Explicit %> <% Dim objConnection Dim objRecords Dim objExcel Dim strQuery Dim i Set objConnection = Server.CreateObject("ADODB.Connection") objConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ= " & Server.MapPath("tech_re.mdb") Set objRecords = Server.CreateObject("ADODB.Recordset") strQuery = "SELECT * FROM tblFAQ" objRecords.Open strQuery, objConnection Set objExcel = Server.CreateObject("Excel.Application") objExcel.Workbooks.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ= " & Server.MapPath("excelface.xls") 'Defines the first row i = 3 'Creates the column description objExcel.ActiveSheet.Range("A" & i).Value = "ID" objExcel.ActiveSheet.Range("B" & i).Value = "Category" objExcel.ActiveSheet.Range("C" & i).Value = "Description" objExcel.ActiveSheet.Range("C" & i).Value = "Document ID" i = i + 1 'Fills columns for each recordset While not objRecords.EOF objExcel.ActiveSheet.Range("A" & i).Value = objRecords("ID") objExcel.ActiveSheet.Range("B" & i).Value = objRecords("Category") objExcel.ActiveSheet.Range("C" & i).Value = objRecords("Description") objExcel.ActiveSheet.Range("D" & i).Value = objRecords("Doc_ID") objRecords.MoveNext i = i + 1 Wend 'Saves file and close Excel objExcel.ActiveWorkbook.SaveAs("excelface (" & Date & ").xls") objExcel.ActiveWorkbook.Close objExcel.Workbooks.Close objExcel.Quit %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Create a pricelist with ASP</title> </head> <body> Pricelist has been created successfully. </body> </html> -------------------------------------------------------------------------------- This code is supposed to write data from access database to excel spreadsheet. But it doesn't work. What should I do? ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Exporting access database to Excel spreadsheet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|