Need to import data into an excel 2007 (.xlsx) file

Hi,

I need to import data into an existing excel 2007 ".xlsx" file. The file is stored in a uri location as opposed to a physical path location. I even tried accesing the file from a physical path. However the code breaks at the following line

Workbook workbook = new Workbook();

FileStream fstream = new FileStream("D:\\Test\\Book1.xlsx", FileMode.Open);

*** workbook.Open(fstream,FileFormatType.Excel2007Xlsx);

I get an exception stating that "Operation could destabilize the runtime". Kindly advice in this regard. I'm however able to add data to an excel 2003 (.xls) file.

Thanks

Hi,

Could you post your template xlsx file here.

Thank you.

Hi ,

i have attached the sample template with this mail

Thanks

Hi,

Thanks for considering Aspose.

Well, your template (Report.xlsx) file contains charts and chart support is still to be incorporated related Excel2007 Xlsx files. We are working on this feature and chart support will available soon.

Thanks for being patient!

Hi,

Thanks for the reply. I had one more query to ask. Is it possible to load the XLSX template file from a URI Location rather than a physical path? I had tried doing so but again it throws an exception stating that "URI formats are not supported".

Thanks!

Hi,

Thanks for considering Aspose.

Well, you may make your own code to get the excel file into memory streams from web and later use Workbook.Open() method.

Could the sample help you:

//Define memory stream object
System.IO.MemoryStream obj;
//Define web client object
System.Net.WebClient objwebClient;
//Define a string which will hold the web image url...this is just a fake url.
string sURL = "http://files.myopera.com/Mickeyjoe_irl/files/abc.xlsx";
//Instantiate the web client object
objwebClient = new System.Net.WebClient();
//Now, extract data into memory stream downloading the image data into the array of bytes
obj = new System.IO.MemoryStream(objwebClient.DownloadData(sURL));
//Create a new workbook
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
//Open the file.
wb.Open(obj,FileFormatType.Excel2007Xlsx);
.

.

Thank you.