Excel not working on server- works locally


#1

Hi, we use your Aspose.Excel to create an Excel document on the fly from some data. It works fine on the local machine when testing and on other machines here, but when we put it on the server and access it, it doesn’t create the Excel document, it re-opens the .aspx page into an excel document if you choose “open” from the Internet Explorer prompt, or saves a blank excel document if you choose “save” from the prompt.

Do you have any ideas what we are doing wrong? The server doesn’t have Excel on it, but we have tested it on machines here without Excel and it has opoened fine.

Thanks

Richard


#2

It may be a configuration problem in your server. Do you use http compression, https or any other special setting in IIS?

You can try the following method to verify if it’s a config problem:

1. Use a simple manually created excel file as template.

2. Use the following code the stream the file from your live web server to client:

[C#]

FileStream fs1 = new FileStream(“d:\book1.xls”, FileMode.Open, FileAccess.Read);
byte[] data1 = new byte[fs1.Length];
fs1.Read(data1, 0, data1.Length);

this.Response.ContentType = “application/xls”;
Response.AddHeader( “content-disposition”,“inline; filename=book1.xls”);
Response.BinaryWrite(data1);
Response.End();

[VB]
Dim fs1 As FileStream = New FileStream(“d:\book1.xls”,FileMode.Open,FileAccess.Read)
Dim data1() As Byte = New Byte(fs1.Length) {}
fs1.Read(data1, 0, data1.Length)

Me.Response.ContentType = “application/xls”
Response.AddHeader(“content-disposition”,“inline; filename=book1.xls”)
Response.BinaryWrite(data1)
Response.End()


Please try to see if the streamed file works fine.


#3

Hi,
Thanks for your prompt reply. Unfortunately, even this didn’t work. It still tried to open up the .aspx page.

Just to confirm, I used the following code:

string file = HttpContext.Current.Server.MapPath("~/Documents/NQTManager/Reports/book1.xls");

FileStream fs1 = new FileStream(file, FileMode.Open, FileAccess.Read);
byte[] data1 = new byte[fs1.Length];
fs1.Read(data1, 0, data1.Length);
this.Response.ContentType = “application/xls”;
Response.AddHeader( “content-disposition”,“inline; filename=book1.xls”);
Response.BinaryWrite(data1);
Response.End();

…with a book1.xls manually created Excel sheet, which was just a blank sheet. Was this right?

Do you have any ideas where we need to go from here?

Thanks

Richard


#4

Hi Richard,

That may be a problem of IIS configuration. Do you use any special settings for your server’s IIS? I use default settings and I think your development machine also use default settings.

What’s the IIS tcp port?


#5

as far as anyone here is aware, the server uses standard settings. The tcp port is 80. What settings could be the cause of a problem like this so that we can look into them deeper.


Thanks

Richard


#6

Hi Richard,

Is your client browser in the same machine of your server? Have you tried in another machine? What if you use the following sample code:

string file = HttpContext.Current.Server.MapPath("~/Documents/NQTManager/Reports/book1.xls");

FileStream fs1 = new FileStream(file, FileMode.Open, FileAccess.Read);
byte[] data1 = new byte[fs1.Length];
fs1.Read(data1, 0, data1.Length);
this.Response.ContentType = “application/xls”;
Response.AddHeader( “content-disposition”,“attachment; filename=book1.xls”);
Response.BinaryWrite(data1);
Response.End();


#7

Hi Laurence,
Using a browser on the server makes no difference. We can access the excel sheet from local machines, using other computers on the network.

The script that you gave me didn’t work either.

Thanks

Richard


#8

Hi Richard,

It must be a config issue. But I don’t have an idea about what caused this problem because I cannot know more settings in your server machine and server IIS.

Since your problem works well on your development machine, please check the difference of settings in your server and local machine. If you still cannot find the clues, please try:

1. Grant enough rights to your web application. Your program can temporarily save file on server and provide a hyperlink to created files.

2. Have you tried to reboot your server? In March, another user met a similar problem. We cannot figure out the problem. But after a reboot, all work fine again.

3. Installing all new windows patches can also solve some odd problems.

4. If all cannot work and if possible, re-install the server and make all settings as your development machine.