convert to number format

  • Thread starter Thread starter Tommy
  • Start date Start date
T

Tommy

i'm writing code in C# that uses a string array to insert a row of
fields into an excel sheet, at the end of the excel sheet i have a cell
that is suppose to calculate the total of a column, it won't add the
total because my numbers are being inserted as text, any easy fixes??
 
Hi
could you post the relevant part of your code that inserts the values
in Excel
 
well it's actually kind of tricky, i grab a bunch of pay roll
information and create an area for each cell in a row, then i add that
row to an array of rows for the whole page and then i add it to excel,
but theres a bunch of extra formatting i do

for(int i = 0; i < pagearray.Length; i++)
{
//add 2 to the array to add values in after the headers
int irow = i + 2;
Excel.Range range = (Excel.Range)sheet.Cells.get_Range("A" +
irow.ToString().Trim(),"P" + irow.ToString().Trim());
range.Value2 = pagearray;

//this is the relevant part of the code
 
Hi
if each element in your pagearray is a numeric value why not convert it
to a number before inserting it into Excel (don't know the C# syntax
for this).

--
Regards
Frank Kabel
Frankfurt, Germany

well it's actually kind of tricky, i grab a bunch of pay roll
information and create an area for each cell in a row, then i add that
row to an array of rows for the whole page and then i add it to excel,
but theres a bunch of extra formatting i do

for(int i = 0; i < pagearray.Length; i++)
{
//add 2 to the array to add values in after the headers
int irow = i + 2;
Excel.Range range = (Excel.Range)sheet.Cells.get_Range("A" +
irow.ToString().Trim(),"P" + irow.ToString().Trim());
range.Value2 = pagearray;

//this is the relevant part of the code

Frank said:
Hi
could you post the relevant part of your code that inserts the values
in Excel
 
Good point, as simple as that solution it escaped me, thanks a lot

Frank said:
Hi
if each element in your pagearray is a numeric value why not convert it
to a number before inserting it into Excel (don't know the C# syntax
for this).

--
Regards
Frank Kabel
Frankfurt, Germany

well it's actually kind of tricky, i grab a bunch of pay roll
information and create an area for each cell in a row, then i add
that

row to an array of rows for the whole page and then i add it to
excel,

but theres a bunch of extra formatting i do

for(int i = 0; i < pagearray.Length; i++)
{
//add 2 to the array to add values in after the headers
int irow = i + 2;
Excel.Range range = (Excel.Range)sheet.Cells.get_Range("A" +
irow.ToString().Trim(),"P" + irow.ToString().Trim());
range.Value2 = pagearray;

//this is the relevant part of the code

Frank Kabel wrote:

Hi
could you post the relevant part of your code that inserts the
values
in Excel

--
Regards
Frank Kabel
Frankfurt, Germany


Tommy wrote:


i'm writing code in C# that uses a string array to insert a row of
fields into an excel sheet, at the end of the excel sheet i have a
cell that is suppose to calculate the total of a column, it won't
add the total because my numbers are being inserted as text, any
easy fixes??

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top