Convert numbers stored as text to numbers

Hi,

I am facing problem of "Convert numbers stored as text to numbers",It is showing cell with a green error indicator.

how to resolve this problem.Pls find excel as attached.

Thanks,

Arun

Hi Arun,

How do you put those values to an Excel file?

If you use the following code:

cell.PutValue("21%");

You put a string to a cell. To convert it to number, please try this piece of code:

cell.PutValue("21%", true);

Hi,

It is not working still it is giving same problem.

Dim strContMarging As String = FormatPercent(ds.Tables(0).Rows(intCount).Item("% Contribution Margin"), 0)

cells.Item(intRowCounter, 14).PutValue(strContMarging, True)

I am using above code.

Thanks,

Arun

Please download and try v3.6.1.

Hi,

I could able to get v3.6.1 path,i tried with V3.6.0,still it is not working with this.

Thanks,

Arun

Please check my sample code and output file:

Excel excel = new Excel();

excel.Worksheets[0].Cells["A1"].PutValue("21.5%", true);
excel.Worksheets[0].Cells["A1"].Style.Number = 10;


excel.Save(@"d:\test\abc.xls");

Hi,

I have downloaded Aspose.Excel.3.6.1.0 version and written below code to convert string to numbers.

But still it is giving problem.Please find the excel which i generated as attachment.

Dim excel As Excel = New Excel

Dim sheetIndex As Integer = excel.Worksheets.Add(SheetType.Worksheet)

Dim sheet1 As Worksheet = excel.Worksheets(sheetIndex)

Dim cells As Cells = sheet1.Cells

cells.Item(0, 0).Style.Custom = "$#,##0_);[Red]($#,##0)"

cells.Item(0, 0).PutValue(-12.34)

cells.Item(1, 0).Style.Custom = "$#,##0;$-#,##0"

cells.Item(1, 0).PutValue(12.34)

cells.Item(2, 0).PutValue("21%")

cells.Item(2, 1).PutValue("21%", True)

'excel.Worksheets[0].Cells["A1"].Style.Number = 10

cells.Item(2, 1).Style.Number = 10

excel.ChangePalette(Color.LightYellow, 55)

cells.Columns(1).Style.ForegroundColor = Color.LightYellow

cells.Columns(1).Style.Pattern = BackgroundType.Solid

excel.Save("c:\arun\abc.xls")

Thanks,

Arun

Sorry. V3.6.1 does have this problem. I fixed this bug but haven't released it publicly.

Please try this attached version.

I see this problem was supposed to have been address in 2003. I am encountering the same thing with the latest version. What is the solution here?

Hi Robert Horn,


Could you provide us sample code (runnable) or preferably a sample console application (runnable) to reproduce the issue on our end, we will check it soon. Also provide us your template Excel file(s) (if you have any).

Thank you.

Sorry, I made a mistake on this. I was changing the wrong piece of code. I have it working now.

Hi Robert,


It is good to know that you are able to figure out the problem cause. Please feel free to contact us back in case you need our assistance with Aspose APIs.