Free Support Forum - aspose.com

Put the fields in top row

Hi,

I have a set of fields , datebox, decimal box, drop down box etc. I want to show all of them in a single row on a spreadsheet. in the top most row. Could you please suggest how to increment the count of cell one by one and then place my fields in cells A1,B1,C1 then D1…

Also is their any way to read the text from the excel sheet in any specific format and not as plain text. for eg… if i fix a column to put decimal value, then while reading, it should be read as numeric and not text …
I hope both the questions makes sense …

Thanks for replying.

cheers

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Shalini:
I have a set of fields , datebox, decimal box, drop down box etc. I want to show all of them in a single row on a spreadsheet. in the top most row. Could you please suggest how to increment the count of cell one by one and then place my fields in cells A1,B1,C1 then D1..............

Well, for iteration you may use Cells[int RowIndex,int ColumnIndex] collection. I am not very clear what you mean by “fields” but you may check the following sample code which explains how to put values into first four cells of first row by iterating the cells collection:

//initialize the workbook object

Workbook book = new Workbook();

//Get the first worksheet in the workbook

Worksheet sheet = book.Worksheets[0];

//Get Cells collection in the worksheet

Cells cells = sheet.Cells;

for (int i = 0; i < 4; i++)

{

//Iterate through the cells and put the value

cells[0, 1].PutValue(i + 1);

}

//Save the workbook

book.Save(@"C:\Test_Temp\excel.xls");

If you are still face any problem, please manually create an Excel file using MS Excel and share it here and we will provide you the code segment more suitable as per your exact requirement.

Shalini:
Also is their any way to read the text from the excel sheet in any specific format and not as plain text. for eg.... if i fix a column to put decimal value, then while reading, it should be read as numeric and not text ....

You may use Cell.Value property to get the actual value of the cell as per your requirement.

Thank You & Best Regards,

You may use Cell.Value property to get the actual value of the cell as per your requirement.


and what about vice versa ??
i.e. when i put the value on spreadsheet, I want to put numbers as numeric , and string as text value … right now, when i put value in cell A1 , I write A1.PutValue = “123”. where 123 is a text. How to put the numeric value as a number in spreadsheet so that later I can perform mathematical operations on the spreadsheet.

thanks for replying.
Shalini

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />Hi Shalini,

Thank you for considering Aspose.

Well, you can use different data types in the Cell.PutValue method as per your requirement. For numeric value 123, you may simply use Cell.PutValue(123). Please see the list of the Cell.PutValue overloads available using the following documentation link:

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/aspose.cells.cell.putvalue_overloads.html

Thank you & Best Regards,