Format translate data between visual Foxpro and Excel

Hi, I am working in Visual Foxpro, and I am doing report to expor data to excel from visual foxpro 9.0

so, when the transate the data from cursor, the number decimal is rounded to two decimal and I need work with four decimal, something this:

oRange.Columns[07].Value = cursorName.DataCurrency

where cursorName.DataCurrency is value 9234.2678 but when the data is passed to oRange.Columns[07].Value, the data was changed for 9234.27. and I need with the data with four decimals number.

I probed with the column format, and not work.

I probed with Set Decimals to and Not work.

I probed with Set Setting from visual foxpro, but I don´t find solution

Thank you for you help.

Hi,

Well, we appreciate if you could use our Aspose.Cells for .NET component. It is a feature rich component that can perform almost all the task that MS Excel has. The component is more reliable, stable with enhanced performance. It is much better than Office Automation or other solutions.

For your case, I think you may set custom number format to apply on your desired column range.
I am not familiar with Visual Foxpro, But, I will write a sample code in C# and VB.NET for your reference. The code will show which API of Aspose.Cells for .NET you may use to accomplish the task. I think you may use these API in Visual Foxpro accordingly to its language standards.

The output file is also attached for your reference:

Sample code:

[C#]

//Instantiate a new workbook.
Workbook wb = new Workbook();
//Get the first (default) worksheet.
Worksheet sheet = wb.Worksheets[0];
//Get the cells in the worksheet.
Cells cells = sheet.Cells;
//Get the A1 cell.
Aspose.Cells.Cell cell = cells[“A1”];
//Insert a value.
cell.PutValue(9234.2678);
//Get A2 cell.
cell = cells[“A2”];
//Insert a value.
cell.PutValue(987654.23436); 

//Define a style object.
Style style;
//Define style flag object.
StyleFlag flag;

//Create the style object(adding new to the workbook styles collection).
style = wb.Styles[wb.Styles.Add()];
//Set the custom number (currency)formattings for your need.
style.Custom = “$#,##0.0000”;
flag = new StyleFlag();
//Apply the number format(on).
flag.NumberFormat = true;
//Apply the style formatting to the first whole column.
sheet.Cells.ApplyColumnStyle(0, style, flag);

//Autofit first column.
sheet.AutoFitColumn(0); 

//Save the excel file.
wb.Save(“f:\test\currency_four_dec.xls”);

[[VB.NET](http://VB.NET)]

'Instantiate a new workbook.
Dim wb As New Workbook()
'Get the first (default) worksheet.
Dim sheet As Worksheet = wb.Worksheets(0)
'Get the cells in the worksheet.
Dim cells As Cells = sheet.Cells
'Get the A1 cell.
Dim cell As Aspose.Cells.Cell = cells(“A1”)
'Insert a value.
cell.PutValue(9234.2678)
'Get A2 cell.
cell = cells(“A2”)
'Insert a value.
cell.PutValue(987654.23436)

'Define a style object.
Dim style As Style
'Define style flag object.
Dim flag As StyleFlag

'Create the style object(adding new to the workbook styles collection).
style = wb.Styles(wb.Styles.Add())
'Set the custom number (currency)formattings for your need.
style.Custom = “$#,##0.0000”
flag = New StyleFlag()
'Apply the number format(on).
flag.NumberFormat = True
'Apply the style formatting to the first whole column.
sheet.Cells.ApplyColumnStyle(0, style, flag)

'Autofit first column.
sheet.AutoFitColumn(0)

'Save the excel file.
wb.Save(“f:\test\currency_four_dec.xls”)

Also, we recommend you to browse Aspose.Cells for .NET documentation:
Developers Guide

You can also check the featured demos:

Thank you.