CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeCharge.Discussion

 TIP: Creating Excel files with CodeCharge

Print topic Send  topic

Author Message
CodeCharge
Posted: 08/08/2001, 6:32 PM

This works with ASP&Templates:
Open the Page Properties (not Form Properties) and in the Open Event enter
this code:

'No Header or Footer needed
sHeaderFileName=""
sFooterFileName=""
Response.Buffer = TRUE
'Change HTML header to specify Excel's MIME content type
Response.Contenttype="application/vnd.ms-excel"

That's it. This page will now open in MS Excel format, or the user should be
able to save its output as Excel file.
You should consider placing only one grid on such page and unchecking all
options in Form Properties ([ ] Allow Sorting, [ ] Allow Insert, [ ] Page
Navigation).


In PHP&Templates this Page Open Event should work:
$header_filename = "";
$footer_filename = "";
Header("Content-type: application/vnd.ms-excel");


Jaroslav Steigauf
Posted: 08/08/2001, 9:47 PM

The other tip is with Automation Officce such as

Dim xlWorkSheet ' Excel Worksheet object
Dim xlApplication
Set xlApplication = CreateObject("Excel.Application")
xlApplication.Visible = False
xlApplication.Workbooks.Add
Set xlWorksheet = xlApplication.Worksheets(1)

'---------------------------------------------------------------------------
' The SQL below selects all the records from the Table categories
'---------------------------------------------------------------------------
msql = "SELECT * FROM categories"
Set RS=Conn.Execute(msql)

'---------------------------------------------------------------------------
' The The following code generates the header of the Excell spreadsheet
'---------------------------------------------------------------------------
xlWorksheet.Cells(1,1).Value = "categories_name"
xlWorksheet.Cells(1,1).Interior.ColorIndex = 24

iRow = 2
If Not RS.EOF Then

Do Until RS.EOF
For i = 0 To RS.fields.Count-1
xlWorksheet.Cells(iRow,i + 1).Value = RS.fields(i)
xlWorkSheet.Cells(iRow,i + 1).Interior.ColorIndex = 2
Next
iRow = iRow + 1
RS.MoveNext
Loop

End If
strFile = myfilename
xlWorksheet.SaveAs Server.MapPath(".") & "\" & strFile & ".xls"
xlApplication.Quit ' Close the Workbook

Set xlWorksheet = Nothing
Set xlApplication = Nothing
Set RS = Nothing
Dim xlWorkSheet ' Excel Worksheet object
Dim xlApplication
Set xlApplication = CreateObject("Excel.Application")
xlApplication.Visible = False
xlApplication.Workbooks.Add
Set xlWorksheet = xlApplication.Worksheets(1)

'---------------------------------------------------------------------------
' The SQL below selects all the records from the Table categories
'---------------------------------------------------------------------------
msql = "SELECT * FROM categories"
Set RS=Conn.Execute(msql)

'---------------------------------------------------------------------------
' The The following code generates the header of the Excell spreadsheet
'---------------------------------------------------------------------------
xlWorksheet.Cells(1,1).Value = "categories_name"
xlWorksheet.Cells(1,1).Interior.ColorIndex = 24

iRow = 2
If Not RS.EOF Then

Do Until RS.EOF
For i = 0 To RS.fields.Count-1
xlWorksheet.Cells(iRow,i + 1).Value = RS.fields(i)
xlWorkSheet.Cells(iRow,i + 1).Interior.ColorIndex = 2
Next
iRow = iRow + 1
RS.MoveNext
Loop

End If
strFile = myfilename
xlWorksheet.SaveAs Server.MapPath(".") & "\" & strFile & ".xls"
xlApplication.Quit ' Close the Workbook

Set xlWorksheet = Nothing
Set xlApplication = Nothing
Set RS = Nothing
Response.Write("Click <A HRef=" & strFile & ".xls>Here</A> to get XLS file")


"CodeCharge" <support@codecharge.com> wrote in message
news:9ksp6r$cl7$1@news.codecharge.com...
> This works with ASP&Templates:
> Open the Page Properties (not Form Properties) and in the Open Event enter
> this code:
>
> 'No Header or Footer needed
> sHeaderFileName=""
> sFooterFileName=""
> Response.Buffer = TRUE
> 'Change HTML header to specify Excel's MIME content type
> Response.Contenttype="application/vnd.ms-excel"
>
> That's it. This page will now open in MS Excel format, or the user should
be
> able to save its output as Excel file.
> You should consider placing only one grid on such page and unchecking all
> options in Form Properties ([ ] Allow Sorting, [ ] Allow Insert, [ ] Page
> Navigation).
>
>
> In PHP&Templates this Page Open Event should work:
> $header_filename = "";
> $footer_filename = "";
> Header("Content-type: application/vnd.ms-excel");
>
>
>


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.