Problems with reading valules from xlsx file

Hi,

I am using Aspose.cells version 4.6.0.13
While debuging i see the number of sheet, rows and columns are proper. Still the values can not be read :-(. Attached is the sample excel file as suggested by Shahzad Latif on tweeter

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please download and try the latest version:
Aspose.Cells for .NET 7.2.0
and let us know your feedback.

The latest version has major improvements and enhancements, so we strongly recommend you to upgrade your code.

If the problem still occurs with the latest version, we will also need your sample code replicating the problem.

Hi,


Since you are using very older version e.g v4.6…x to read an Excel 2007 file, I am not sure if it works fine with it because by that time we did not provide full support for Excel 2007/2010 versions.

We strongly recommend you kindly upgrade to latest versions of the product e.g v7.2.0.

Moreover, with the release of Aspose.Cells for .NET version v5.0.0, we have re-organized the API classes for Aspose.Cells component. This change has some major aspects that we follow. We have added new namespaces. All the API (classes, interfaces, enumerations, structures etc.) were previously located in the Aspose.Cells namespace. Now, certain sets of API have been moved to their relative namespaces, which make the relationship of classes (with their members) and namespaces clear and simplified.

Namespaces
All classes in Aspose.Cells are split into appropriate namespaces for easy access. The Aspose.Cells namespace is of course the root namespace that provides classes for generating, converting, modifying, rendering and printing Microsoft Excel documents without utilizing Microsoft Excel.

Namespaces in Aspose.Cells for .NET
Aspose.Cells
Aspose.Cells.Charts
Aspose.Cells.Drawing
Aspose.Cells.Rendering
Aspose.Cells.Rendering.PdfSecurity
Aspose.Cells.Pivot
Aspose.Cells.Tables
Aspose.Cells.Properties
Aspose.Cells.Markup
Aspose.Cells.DigitalSignatures
etc.

Please check the Programmer’s Guide:

See the API Reference Pages:


In short, you need to update your code a bit in accordance with latest API model of Aspose.Cells.

Please use latest version (v7.2.0) and let us know if you still find the issue, we will check it soon.


Thank you.

Hi Amjad,


Thanks for the prompt response.

We have already updated the latest version , now this states about the license issue
"The subscription included in this license allows free upgrades until 10 Feb 2010, but this version of the product was released on 12 Apr 2012. Please renew the subscription or use a previous version of the product."

Is there any update prior to this 10th Feb 2010, which will help us out

Hi,


We do not provide any versions/fixes older than one year, so you cannot get any fixes before your subscription expiry that is sure. The error you are getting states that you cannot use latest versions with your license file, so you need to re-update your subscription.

This is the only option left for you i.e., to upgrade your subscription to use latest versions/fixes.
I think first of all you can test your case with v7.2.0, you may comment out your licensing code and update your codes in accordance with latest APIs set. Then you may contact Aspose.Purchase team (in their forum) for up-gradation of your subscription.

Thank you.

HI Amjad,


Tried the latest version. It is still the same. Have you checked and tested the file which is orignally attached in the first post. The values are not read :frowning:
Please check an additional attachement. The first part shows the stream length properly, and after executing the workbook.open method, the stream length becomes 0, also we see some ReadTimeOut and WriteTimeOut error

Hi,

It works fine with it, I can read the values fine in the sheets, here is my sample code and below is the output:

Sample code using a Winform application:

Workbook workbook = new Workbook(“e:\test2\ExcelUploadTemplate.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;

foreach (Aspose.Cells.Cell cell in cells)
{
if (cell.Value != null)
{
Debug.WriteLine(cell.Value);
Debug.WriteLine(cell.Name);
}

}

Output (Window) of VS.NET:

You downloaded this template on:
A1
4/17/2012 12:26:47 PM
B1
Please regularly download the latest template
C1
Jeweller Name
F1
Ben Bridge Jeweler
G1
Location
I1
United States
J1
Forevermark Identification Number
A2
Carat Weight
B2
Piece Type Description
C2
Style Type
D2
Metal Type
E2
Date Sold
F2
Internal Sku
G2
Forevermark Sales Ambassador
H2
Total Price
I2
Currency
J2
Store Name
K2
1234678
A3
1
B3
Brooch
C3
Designed, other
D3
Platinum
E3
test
G3
Forevermark Sales Ambassador
H3
Ala Moana Center
K3

Please paste your runnable code using v7.2.0 same as mine to show the issue, we will check it soon.

Thank you.

Hi Amjad,

The issue is with the stream. The stream data is disturbed. Please check the code below

public bool doesContainsErrorColumn(string fileName, Stream data, string pageLanguageId)
{
errorColumnHeader = ForevermarkLanguageManager.Instance.Translate("/excelFile/errorMessage", pageLanguageId);
string ext = getFileExtension(fileName);
Workbook wb = new Workbook();

switch (ext)
{
case “xls”:
wb.Open(data, FileFormatType.Default);
break;
case “xlsx”:
// here the value of data is proper - check the length
wb.Open(data, FileFormatType.Excel2007Xlsx);
// now the value of data is incorrect - check the length - this works fine with xls file
break;
default:
wb.Open(data);
break;
}

///wb.LoadData(data);

Worksheet ws = wb.Worksheets[0];
string columnHeader = ws.Cells[1, ws.Cells.MaxDataColumn].StringValue;

if (columnHeader.Equals(errorColumnHeader))
return true;
else
return false;
}

Hi,


Since you are using your own code and obtaining data from your own source stream for which I am not sure about it.
Please simply open the file using Workbook’s constructor, e.g
Workbook workbook = new Workbook(“e:\test2\ExcelUploadTemplate.xlsx”);

Or even I obtain file from stream to be loaded by Aspose.Cells for .NET v7.2.0, it still works fine. Here is my sample code:

FileStream stream = File.OpenRead(“e:\test2\ExcelUploadTemplate.xlsx”);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
Workbook workbook = null;
using (MemoryStream templateStream = new MemoryStream(buffer))
{
workbook = new Workbook(templateStream); // Fetch template
}

Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;

foreach (Aspose.Cells.Cell cell in cells)
{
if (cell.Value != null)
{
Debug.WriteLine(cell.Value);
Debug.WriteLine(cell.Name);
}

}

As requested to you, if you got issue with Aspose.Cells component, you should separate it and show us to reproduce it on our end. It should not depend on your custom resources or other pointers / objects. If you still could not evaluate, kindly create a sample console application with v7.2.0 only (you should use some hard codes or System.IO APIs to get the files from streams to be loaded by the product), zip it and post it here to show the issue. We will check it soon.

Thank you.

Hi Amjad,


I am using an FileUpload in my .aspx page
get the FileUpload.PostedFile.InputStream in Stream object
Open the file using the same stream using workbook.open(stream,FileFormatType.Excel2007Xlsx)

Note:- Now when I do this the stream.Length becomes 0. Tried the same with xls file, it works fine. Check the stream.Length before and after for both xls and xlsx. You will come to know the issue

Hi,


Kindly do create a simple project with v7.2.0, zip it and post it here, we will check it soon.

Thank you.

Hi In the mean time can you tell me how to make this post public. As I need to share this

Hi,

Please click on the Make Public button to make this thread public.

For your help, I have made this thread public, if you want to make it private again then please click the same button which now shows Make Private text.

Thanks Amjad. I read the same on your help page. But I still can not see any of these buttons. Never mind the purpose of making it public is solved

Hi,

Please see the Make Public/Private button in a screenshot below.

Screenshot:

Hi,


By the way, your thread/post is already Publically available by default.

Thanks,

Hi Amjad I do not see those buttons

Hi,

Thanks for your image.

By looking at this image, I found these rights are only for Aspose Staff Members.

Sorry for inconvenience.

Thanks,


So can you help me out, how I can make it private/ public in future

Hi,

If the button is available, then use it to make Public/Private. In case, it is not available, then please ask us, we will make it public or private for you.