Reply to topic  [ 8 posts ] 
Can't Upload a XLSX File 
Author Message

Joined: Mon May 11, 2009 5:47 pm
Posts: 6
Reply with quote
Post Can't Upload a XLSX File
Hi,

I am new in this forum as with EasyXLS.

I am having an issue trying to read an XLSX file. The code i am using was developed before I arrived to the project, and can have some problems, and noone knows if it ever worked. Now i checked on the tutorials, and it seems it should work. Probably i am missing something, but i don't really know what it is. I would really appreciate if you could help me with this issue.

The application should allow upload files from XLS or XLSX, so the code that reads the data from the excel is something like (the file was previously uploaded with a fileuploader):

Code:
public DataSet GetExcelData(byte[] xlsStream)
        {
            ExcelDocument xls = new ExcelDocument();
            DataSet ds = new DataSet();

            //Load the excel into the DataSet
            if ((xls.easy_LoadXLSFile(new MemoryStream(xlsStream))) || (xls.easy_LoadXLSXFile(new MemoryStream(xlsStream))))
            {
                /*Does something*/
            }
            else
            {
                return null;
            }

            return ds;
        }


The problem is that for XLS files is working perfectly. But for XLSX is not working at all, it always returns false.

Now i would assume the previous developer tested the application for both excel versions and it worked for him. But the only difference I have with his environment, is the version of EasyXLS. He was using the v6.1, and i am using the EasyXLS Reader for .Net - Developer Edition v6.3.

Can anyone help me with this?

Thanks.-


Mon May 11, 2009 6:01 pm
Profile

Joined: Wed Nov 07, 2007 4:42 am
Posts: 67
Reply with quote
Post Can't Upload a XLSX File
Hi,

ExcelDocument.easy_LoadXLSFile method is working with memory stream but ExcelDocument.easy_LoadXLSXFile is not, because EasyXLS needs the HDD to extract the archive of xlsx file.


Tue May 12, 2009 5:50 am
Profile WWW

Joined: Mon May 11, 2009 5:47 pm
Posts: 6
Reply with quote
Post 
Hi Oana, thanks for answering me.

I am sorry but i don't really quite understand your answer. You mean that there is not available a method that could extract from memory the XLSX file? I checked the documentation and saw there was 2 implementations for upload an excel, both for XLS files and XLSX files. So i wouldn't know why it would work for XLS and not for XLSX.

The implementations i am talking about are:
For XLS:
-public bool easy_LoadXLSFile(System.IO.Stream f)
-public bool easy_LoadXLSFile(System.String sPath)

For XLSX:
-public bool easy_LoadXLSXFile(System.IO.Stream f)
-public bool easy_LoadXLSXFile(System.String sPath)

So i see that for loading XLS and XLSX are available 2 ways, and i dont understand why it would work for XLS and not for XLSX.

Maybe i understood you wrong?

Regards.-


Tue May 12, 2009 8:31 am
Profile

Joined: Wed Nov 07, 2007 4:42 am
Posts: 67
Reply with quote
Post Can't Upload a XLSX File
Hi,

For ExcelDocument.easy_LoadXLSFile(System.IO.Stream f), System.IO.Stream can be any stream.

For ExcelDocument.easy_LoadXLSXFile(System.IO.Stream f), System.IO.Stream has to be a stream that points to a file on the HDD because EasyXLS needs the HDD to extract the archive of xlsx file.


Wed May 13, 2009 4:21 am
Profile WWW

Joined: Mon May 11, 2009 5:47 pm
Posts: 6
Reply with quote
Post 
Thanks Oana for your answer.

I have tested diferent aproachs, and finaly found one that works. The
tried to use a FileStream, but it wouldn't work either.

Just the overload that receives a file path worked, after that had a minor problem that i could solve with the information on a thread of this forum,
wich was curious because it wouldnt happen when exporting from a excel of older versions.

Is just not clear for me, why would be this the only aproach that worked, and why there doesn't seem to be anything related to what you mentioned in the documentation about that method.

Thanks for your answers again!

Regards.-


Wed May 20, 2009 2:49 pm
Profile

Joined: Mon May 11, 2009 5:47 pm
Posts: 6
Reply with quote
Post 
Hi Again.

This issue after the solution i found was posponed in my project because we did not like it.

We have been doing further analysis, and found that each time we were reading an XLSX file, the method "xls.easy_getError()", had this error:
"Access to the path 'C:\WINDOWS\system32\EasyXLS_633795635597208236' is denied.

Invalid file format!"

We did not know well what to do, so just for trying, we copied the EasyXLS.dll to the system32 folder.
But after testing the method had still the same error. So we gave permisions to everyone (just for the sake of testing) in system32, and found that now our code was working perfectly.

We would like to know why is that for this method we need to copy the DLL in that folder and not when we are uploading a 2003 excel file. Are we configuring something wrong?


Regards.-


Tue Jun 02, 2009 4:43 pm
Profile

Joined: Fri Feb 03, 2006 12:23 pm
Posts: 199
Location: Brasov, Romania
Reply with quote
Post 
The xls file format is a binary format.

The xlsx file format is basically a zip file. EasyXLS needs a place to extract the archive. In case that no path was supplied, as a MemoryStream, EasyXLS uses the Environment.CurrentDirectory to extract the files. In your case this application variable is set to 'C:\WINDOWS\system32'. The access on this folder is forbidden.

So for xls files the files is read directly from the MemoryStream, but for xlsx the file from the MemoryStream is extracted on HDD.

This is why it works for xls files and does not work for xlsx files.

I hope this will help you to find a workaround in your case.


Wed Jun 03, 2009 8:14 am
Profile WWW

Joined: Mon May 11, 2009 5:47 pm
Posts: 6
Reply with quote
Post 
Hi Daniela,

Thanks for your answer! Now all makes more sense. Was kinda confusing before. And when I would look info for that method i wouldn't find anything related to what you mentioned.

Thanks for you help!

Regards.-


Wed Jun 03, 2009 8:40 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.