kpetti
asked on
Exporting ASP Reports to Excel Format
I am currenly exporting data from my .asp page to Excel. In my code, I dynamically create html tables based on selection a user made on the previous page. For each of these tables, I am creating a separate worksheet in Excel.
How do I:
1. Add only the worksheets that I generate to the Excel workbook (Excel defaults to already having 3 worksheets in the workbook then when I add mine, I have 3 blank worksheets plus the ones I add).
2. How do I arrange the worksheets in the order. Currently, if there are 3 html tables, I generate 3 worksheets. The tabs in my excel workbook look like this: sheet6, sheet5, sheet4, sheet1, sheet2, sheet3.)
3. How do I change the name of the tab using code, from something like: sheet1 to "1999 Activity Report".
4. How can I make the columns autofit using code? And can I bold line 1 and 2 which is the report title and field heading respectively?
5. How can I prompt the user to save the worksheet to there hard drive? Currently, I am using:
xlWorksheet.SaveAs Server.MapPath(".") & "\" & strFile
Thanks,
kpetti
How do I:
1. Add only the worksheets that I generate to the Excel workbook (Excel defaults to already having 3 worksheets in the workbook then when I add mine, I have 3 blank worksheets plus the ones I add).
2. How do I arrange the worksheets in the order. Currently, if there are 3 html tables, I generate 3 worksheets. The tabs in my excel workbook look like this: sheet6, sheet5, sheet4, sheet1, sheet2, sheet3.)
3. How do I change the name of the tab using code, from something like: sheet1 to "1999 Activity Report".
4. How can I make the columns autofit using code? And can I bold line 1 and 2 which is the report title and field heading respectively?
5. How can I prompt the user to save the worksheet to there hard drive? Currently, I am using:
xlWorksheet.SaveAs Server.MapPath(".") & "\" & strFile
Thanks,
kpetti
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi clockwatcher,
I am having trouble using the move method in my ASP page. I keep getting an error:
Microsoft VBScript compilation error '800a0400'
Expected statement
/NetPro/ResultsExcel4-21-2 000.asp, line 250
xlWorkSheets("Sheet1").Mov e after:=xlWorkSheets("Sheet 3")
-------------------------- --------^
xlWorkSheets is a variable I created using the following code:
Dim xlWorkSheets
Set xlWorksheets = objXLApplication.Worksheet s
As you know everything in .asp is type variant so I could not explicitly Dim the variable as Excel.WorkSheets
Any ideas why I am getting this error? Can you not use := in asp? Are there any other alternatives?
Thanks,
kpetti
I am having trouble using the move method in my ASP page. I keep getting an error:
Microsoft VBScript compilation error '800a0400'
Expected statement
/NetPro/ResultsExcel4-21-2
xlWorkSheets("Sheet1").Mov
--------------------------
xlWorkSheets is a variable I created using the following code:
Dim xlWorkSheets
Set xlWorksheets = objXLApplication.Worksheet
As you know everything in .asp is type variant so I could not explicitly Dim the variable as Excel.WorkSheets
Any ideas why I am getting this error? Can you not use := in asp? Are there any other alternatives?
Thanks,
kpetti
VBScript doesn't support named parameters.
Instead of this:
xlWorkSheets("Sheet1").Mov e after:=xlWorkSheets("Sheet 3")
Use this-- just leave the first parameter out; it's optional.
xlWorkSheets("Sheet1").Mov e ,xlWorkSheets("Sheet3")
Instead of this:
xlWorkSheets("Sheet1").Mov
Use this-- just leave the first parameter out; it's optional.
xlWorkSheets("Sheet1").Mov
ASKER
I think I might have over-estimated the complexity of this question. Enjoy the points...
kpetti
kpetti
My .02pts,
Tom