Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default convert to number format

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??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default convert to number format

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??


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default convert to number format

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[i];

//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??




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default convert to number format

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


Tommy wrote:
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,[i]
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??


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default convert to number format

Good point, as simple as that solution it escaped me, thanks a lot

Frank Kabel wrote:
[i]
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


Tommy wrote:

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??



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert number to % using only custom number format challenge Brotherharry Excel Discussion (Misc queries) 7 June 2nd 09 06:29 PM
Convert numbers from text format to number format merlin68 Excel Discussion (Misc queries) 7 June 20th 07 07:03 PM
Convert [h]:mm sum total format to number format Guy Excel Worksheet Functions 1 August 5th 05 05:56 AM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
convert number format to time format fullymooned[_3_] Excel Programming 1 February 23rd 04 03:00 PM


All times are GMT +1. The time now is 02:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"