Hi,
I have uploaded a CSV file.In that file, I am trying to read all the string values in the column C. Now when I am trying to read any such value which has a ‘,’ in its text, I am reading incorrect values. For example if I try to read the value for cell C35 it should give me “PROTEIN, TOTAL”. But it is reading “ALBUMIN” for some reason.
In the C column of this file for the values “PROTEIN, TOTAL”, “ALCOHOL,URINE” and “FOLATE, SERUM” I am facing the same issue.
This is the code that I am using :
Workbook workbook = new Workbook();
workbook.Open(fpath, FileFormatType.CSV);
//Access the first sheet
Worksheet worksheet = workbook.Worksheets[0];
int colIdx = 2;
int DateIdx = DateColNum;
//Find unique values
for (int rowIdx = 1; rowIdx < worksheet.Cells.Rows.Count; rowIdx++)
{
string cellValue = worksheet.Cells[rowIdx, colIdx ].StringValue;
}
Please help out here. Let me know if you need any other information from my end. Please also let me know if there is some problem the file that I am using.
Regards,
Neel
|
|
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
I have tested your issue with the latest version: Aspose.Cells
for .NET v7.2.0.8
and found latest version is working fine.
Since you are using quite an older version, we also strong recommend you to upgrade your code with latest version.
Please see the code below and see its output. As you can see, the output is as expected.
C#
string filePath = @“F:\File.csv”;
Workbook workbook =
new Workbook(filePath);
Worksheet worksheet = workbook.Worksheets[0];
Cell c35 =worksheet.Cells[“C35”];
Debug.WriteLine(c35.StringValue);
Output:PROTEIN,TOTAL
Then why is it that I am not able to read the value? I have give n the code that I am using. Is there something wrong in the code? However, I am using Aspose.Cells for .NET v4.8.1.9. This is strange.
Please let me know what you find. I am stuck with this issue
Hi,
Please accept my apologies for the delayed response.
It might be that you are using an older version of Aspose.Cells that may have this issue. But as you have seen in the earlier posts that our latest version is performing the task fine. We recommend you to upgrade to the latest version of Aspose.Cells to obtain a more stable API and avail support on your issues, as we can’t provide solutions arose due to this much older versions.
I hope you understand our concern. Thank you for using Aspose.Cells
Can you confirm if my code is correct?
Hi,
Apparently it seems fine to me. You can also confirm the accuracy of your code by printing each cell value that you are reading from the file. I am sorry but I am unable to test your code since it is using an older version of Aspose.Cells and its not reproducible by us.
Thank you for using Aspose.Cells
Its not working for me. I cannot read some of the values in the file as mentioned in my first post. Can you please direct me to Amjad? He has helped me before quite a number of times. Version was never a problem for him. Please this is urgent
Hi,
I may not be able to contact Amjad directly. However, I can put an email to him for you. He wiill get to this thread once he reads the email.
Can you check if the Cell.Value member function is supported at your end? If so, please try this line:
cell = Cells[“C35”];
string str = Convert.ToString(cell.Value);
Thanks & Best Regards,
Hi,
Well, I suspect this might be an issue with your older version that you are using, so I am afraid there might be no workaround. To confirm this, you may try a simple code snippet with your version, e.g
Workbook workbook = new Workbook();
workbook.Open(@“F:\File.csv”", FileFormatType.CSV);
Worksheet worksheet = workbook.Worksheets[0];
Cell c35 =worksheet.Cells[“C35”];
Debug.WriteLine(c35.StringValue);
If it does not print “PROTEIN,TOTAL” then it is confirmed that it is an issue with your older version.
I am afraid there is no alternative but to upgrade to latest versions of the product e.g v7.2.0.x as
Shakeel Faiz and Kashif Iqbal suggested.
Thanks for your understanding!