Hey Everybody,
I am here today to bring a problem that I have been trying to solve for a while. I can’t find a solution.
Here is the situation. I have an option to import xls files in my application. The values in my first columns of the xls file are “5.7” and “5.8”. The problem happens when my code tries to read the data from the xls file, the previous values are showed as “5,7” and “5,8”.
What I could understand is that aspose sees the values from the first column as numeric values. I does not happen to the other columns though.
I attached in this post my xls file and a print screen that shows the numeric value that my code is getting.
Has anybody seen this problem???
Sincerely,
Arthur Medeiros.
Hi Arthur,
Hello Barbar,
Well, it turns out that this problem happens to every situation that the user can try to import from xls.
Here
is what I figured, whenever a value of a field in my xls file is
something like “6.5”,“2.4” aspose will see it as a number. Now, if I use
instead “6.5.4”, aspose will treat it as a string. I even tried stuff
like “6.a” and that worked.
Now, is there any way I could force aspose to see all of my rows and columns as string values?
I
already call the StringValue property (as you can see in the attached
file). However, that property already has the value altered.
I appreciate you attention,
Sincerely,
Arthur Medeiros.
Console.WriteLine(cells["A2"].Value + " " + cells["A2"].StringValue); Console.WriteLine(cells["A3"].Value + " " + cells["A3"].StringValue); Console.WriteLine(cells["A4"].Value + " " + cells["A4"].StringValue); Console.WriteLine(cells["A5"].Value + " " + cells["A5"].StringValue); Console.WriteLine(cells["A6"].Value + " " + cells["A6"].StringValue); Console.WriteLine(cells["A7"].Value + " " + cells["A7"].StringValue); Console.WriteLine(cells["A8"].Value + " " + cells["A8"].StringValue); Console.WriteLine(cells["A9"].Value + " " + cells["A9"].StringValue);
var cells = workbook.Worksheets[0].Cells;
Console.WriteLine(cells["A2"].Value + " " + cells["A2"].StringValue + " " + cells["A2"].StringValueWithoutFormat);
Console.WriteLine(cells["A3"].Value + " " + cells["A3"].StringValue + " " + cells["A3"].StringValueWithoutFormat);
Console.WriteLine(cells["A4"].Value + " " + cells["A4"].StringValue + " " + cells["A4"].StringValueWithoutFormat);
Console.WriteLine(cells["A5"].Value + " " + cells["A5"].StringValue + " " + cells["A5"].StringValueWithoutFormat);
Console.WriteLine(cells["A6"].Value + " " + cells["A6"].StringValue + " " + cells["A6"].StringValueWithoutFormat);
Console.WriteLine(cells["A7"].Value + " " + cells["A7"].StringValue + " " + cells["A7"].StringValueWithoutFormat);
Console.WriteLine(cells["A8"].Value + " " + cells["A8"].StringValue + " " + cells["A8"].StringValueWithoutFormat);
Console.WriteLine(cells["A9"].Value + " " + cells["A9"].StringValue + " " + cells["A9"].StringValueWithoutFormat);
Hey Babar,
First of all, sorry for not giving you enough information about my enviroment, but you are right about where I am located. Also, I know that in the USA the dot is the decimal separator, which is different from what we use in Brazil, but I could not to relate that to the problem. I thought that if I had everything in my computer set to be in English, I mean keyboard and language, I would not have that problem.
Anyway, I also did not know that when the cell is set to format as General and has a numeric value, it will be treated as a number.
Thank you very much for your help, I really appreciate it, and I think the problem is solved!
Sincerely,
Arthur Medeiros.
Hi Arthur Medeiros,