Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > From an ASP page, is there a way write to an EXCEL file without having EXCEL installed on the IIS machine ?

Reply
Thread Tools

From an ASP page, is there a way write to an EXCEL file without having EXCEL installed on the IIS machine ?

 
 
fniles
Guest
Posts: n/a
 
      04-24-2009
In my ASP page, I have a button that what it does is writing information to
an EXCEL file.
Currently I am using Server.CreateObject("excel.application") to do that.
Is that correct that in order to do that, the IIS server needs to have EXCEL
installed on it ?
My client does not have EXCEL loaded on their server and will not load it.
Is there any other way to write to an EXCEL file without using without
having to install EXCEL on the IIS server ?
Thank you.

Set spread = Server.CreateObject("excel.application")
spread.Workbooks.Open sExcelPath
spread.ActiveWorkbook.Worksheets("data").Select
iNumCol = 0
for iNumCol = 0 to 3
spread.ActiveWorkbook.ActiveSheet.Cells(1, iNumCol).Value = "col " &
iNumCol
next
spread.DisplayAlerts = False
spread.ActiveWorkbook.SaveAs spath & "\myExcelFile.xls"
spread.DisplayAlerts = True
spread.Workbooks.Close
spread.Quit


 
Reply With Quote
 
 
 
 
Jon Wallace
Guest
Posts: n/a
 
      04-25-2009

In order to write to any file which has a bespoke format (Word document,
PDF, Excel spreadsheet etc...) you need a handler - an API set which can
take input from a program and create the resultant file from it.

Without something installed which has the ability to create such files it's
not possible to write them. What you could try however is moving your code
which creates the excel file client-side so instead of the ASP processing /
creating the spreadsheet, you have a resultant file which has client-side
script in essense doing the same thing. This would of course very much
depend on how complicated your spreadsheet was, how much data was going into
it and where that data was comming from.

In short, no - you need some engine to create the spreadsheet in some form
or another.

Hope this helps,
Jon

www.insidetheregistry.com

---

"fniles" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In my ASP page, I have a button that what it does is writing information
> to an EXCEL file.
> Currently I am using Server.CreateObject("excel.application") to do that.
> Is that correct that in order to do that, the IIS server needs to have
> EXCEL installed on it ?
> My client does not have EXCEL loaded on their server and will not load it.
> Is there any other way to write to an EXCEL file without using without
> having to install EXCEL on the IIS server ?
> Thank you.
>
> Set spread = Server.CreateObject("excel.application")
> spread.Workbooks.Open sExcelPath
> spread.ActiveWorkbook.Worksheets("data").Select
> iNumCol = 0
> for iNumCol = 0 to 3
> spread.ActiveWorkbook.ActiveSheet.Cells(1, iNumCol).Value = "col " &
> iNumCol
> next
> spread.DisplayAlerts = False
> spread.ActiveWorkbook.SaveAs spath & "\myExcelFile.xls"
> spread.DisplayAlerts = True
> spread.Workbooks.Close
> spread.Quit
>


 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      04-25-2009
fniles wrote:
> In my ASP page, I have a button that what it does is writing
> information to an EXCEL file.
> Currently I am using Server.CreateObject("excel.application") to do
> that. Is that correct that in order to do that, the IIS server needs
> to have EXCEL installed on it ?


Of course!

> My client does not have EXCEL loaded on their server and will not
> load it.


Then you will have to give up on automating Excel in server-side code (which
is not a bad thing to have to give up, actually)

> Is there any other way to write to an EXCEL file without
> using without having to install EXCEL on the IIS server ?
> Thank you.


Yes
This should explain things:
http://support.microsoft.com/default...b;en-us;257757

It includes a link to this:
http://support.microsoft.com/kb/199841/

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Bob Riemersma
Guest
Posts: n/a
 
      04-25-2009
"fniles" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In my ASP page, I have a button that what it does is writing information
> to an EXCEL file.
> ...


> My client does not have EXCEL loaded on their server and will not load it.
> Is there any other way to write to an EXCEL file without using without
> having to install EXCEL on the IIS server ?


Any Windows OS of a practical vintage will already have the components
required to create a *basic* Excel workbook with one or more worksheets
filled with data. This is documented in many places, including a number of
MS KB articles.

A limitation is that you have no control over things like cell fonts, column
widths, etc. Even this may be overcome to an extent by copying a
pre-formatted "template" workbook and populating it with data. However the
example below (a WSH script for easy testing) creates a workbook from
scratch in the current directory:

Option Explicit

Private Const adCmdTable = 2
Private Const adLockOptimistic = 3
Private Const adOpenStatic = 3
Private Const adVarWChar = 202

Private catWB, tblWS, rsWS, intRow

Private Sub AddColumn(ByVal Table, ByVal ColName)
Dim Column

Set Column = CreateObject("ADOX.Column")
Column.Name = ColName
Column.Type = adVarWChar 'Can also use numeric types.
Table.Columns.Append Column
End Sub

Set catWB = CreateObject("ADOX.Catalog")
catWB.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='created.xls';" _
& "Extended Properties='Excel 8.0;HDR=Yes'"
Set tblWS = CreateObject("ADOX.Table")
tblWS.Name = "Sample"
AddColumn tblWS, "First"
AddColumn tblWS, "Second"
AddColumn tblWS, "Third"
catWB.Tables.Append tblWS
Set tblWS = Nothing
Set rsWS = CreateObject("ADODB.Recordset")
With rsWS
Set .ActiveConnection = catWB.ActiveConnection
Set catWB = Nothing
.Open "Sample", , adOpenStatic, adLockOptimistic, adCmdTable
For intRow = 2 To 100
.AddNew
.Fields("First").Value = CStr(intRow * 10)
.Fields("Second").Value = CStr(intRow * 100)
.Fields("Third").Value = CStr(intRow + 10000)
.Update
Next
.Close
End With
Set rsWS = Nothing

MsgBox "Complete!", vbOkOnly, "Create Workbook"

 
Reply With Quote
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      04-26-2009
Unless you want your spreadsheets to be opened by versions of Excel 2000 and
before, the easiest way would be to use the SpreadsheetML specification.
XML files are plain text files that can be write by any IO file systems;
including those available with ASP. Don't forget to set the mime type to
Excel; see the last two references below.

http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

http://www.brainbell.com/tutorials/m...cting_Data.htm
http://www.brainbell.com/tutorials/m...eadsheetML.htm

http://support.microsoft.com/default...b;en-us;257757
http://support.microsoft.com/kb/199841/

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)


"fniles" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In my ASP page, I have a button that what it does is writing information
> to an EXCEL file.
> Currently I am using Server.CreateObject("excel.application") to do that.
> Is that correct that in order to do that, the IIS server needs to have
> EXCEL installed on it ?
> My client does not have EXCEL loaded on their server and will not load it.
> Is there any other way to write to an EXCEL file without using without
> having to install EXCEL on the IIS server ?
> Thank you.
>
> Set spread = Server.CreateObject("excel.application")
> spread.Workbooks.Open sExcelPath
> spread.ActiveWorkbook.Worksheets("data").Select
> iNumCol = 0
> for iNumCol = 0 to 3
> spread.ActiveWorkbook.ActiveSheet.Cells(1, iNumCol).Value = "col " &
> iNumCol
> next
> spread.DisplayAlerts = False
> spread.ActiveWorkbook.SaveAs spath & "\myExcelFile.xls"
> spread.DisplayAlerts = True
> spread.Workbooks.Close
> spread.Quit
>



 
Reply With Quote
 
Bill McCarthy
Guest
Posts: n/a
 
      04-27-2009
Hi fniles,

You might find it a lot easier to write out the excel file as xml.


"fniles" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In my ASP page, I have a button that what it does is writing information
> to an EXCEL file.
> Currently I am using Server.CreateObject("excel.application") to do that.
> Is that correct that in order to do that, the IIS server needs to have
> EXCEL installed on it ?
> My client does not have EXCEL loaded on their server and will not load it.
> Is there any other way to write to an EXCEL file without using without
> having to install EXCEL on the IIS server ?
> Thank you.
>
> Set spread = Server.CreateObject("excel.application")
> spread.Workbooks.Open sExcelPath
> spread.ActiveWorkbook.Worksheets("data").Select
> iNumCol = 0
> for iNumCol = 0 to 3
> spread.ActiveWorkbook.ActiveSheet.Cells(1, iNumCol).Value = "col " &
> iNumCol
> next
> spread.DisplayAlerts = False
> spread.ActiveWorkbook.SaveAs spath & "\myExcelFile.xls"
> spread.DisplayAlerts = True
> spread.Workbooks.Close
> spread.Quit
>


 
Reply With Quote
 
Karl E. Peterson
Guest
Posts: n/a
 
      04-27-2009
fniles wrote:
> In my ASP page, I have a button that what it does is writing information to
> an EXCEL file.


RawText.CSV
--
..NET: It's About Trust!
http://vfred.mvps.org


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write updated list to excel without having to close the browser first? Phil ASP .Net 2 01-04-2010 07:05 PM
writing 0x0A to a bin file without having it automatically write 0x0D MCondon77@gmail.com C Programming 15 03-14-2006 08:37 PM
Is there any way to convert an .img file to an .iso file without having a DVD R/RW? Computer Support 1 10-23-2003 03:40 PM
had .NET 1 and installed .NET 1.1 on the IIS machine SStory ASP .Net 1 08-08-2003 10:59 PM



Advertisments