Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Below is the line i am using to format the data

C#
strline = string.Format("{0,-3}", co.ToString()) + 
          String.Format("{0,-19:dd MMM yyyy}", ds.Tables[0].Rows[i][1]) + 
          string.Format("{0,-30}", per1) + 
          string.Format("{0,-40}", ds.Tables[0].Rows[i][3].ToString()) + 
          string.Format("{0,-50}", ds.Tables[0].Rows[i][5].ToString()) + 
          Math.Round(d, 2) + 
          string.Format("{0,-60}", ds.Tables[0].Rows[i][6].ToString()) + 
          Math.Round(d1, 2) + 
          string.Format("{0,-80}", ds.Tables[0].Rows[i][7].ToString());


but the output i am getting is

1  07 Aug 2012        By IB-2012220152498-cash      0   0.0000                                            0.0010938.0000                                                  10938.0044929.00                  


I am not able to separate
0.0010938.0000                            10938.0044929.00 


it should come like this

0.00       10938.0000     10938.00     44929.00 


Sample Data

Date                               Particulars                          ChequeNo                    Withdrawals              Deposits                  Balance
--------------------    -----------------------------------        --------                        -----------------        --------------------         ---------------
1  07 Aug 2012        By IB-2012220152498-cash      0                                       0                                                 10938                                                            44929.00
                                                                  
2  07 Aug 2012        To Cash                       0                                       20000                                             0                                                                24929.00
                                                                  
3  08 Aug 2012        To SI TD/RD/89                                                        8000                                              0                                                                16929.00
                                                                  
4  09 Aug 2012        To Cash                       0                                       5000                                              0                                                                11929.00
                                                                  
5  14 Aug 2012        To Cash                       0                                       11000                                             0                                                                929.00
                                                                    
6  22 Aug 2012        By OUTSTN ALLOW FRM 8/8/1     0                                       0                                                 25676                                                            26605.00
                                                                  
7  24 Aug 2012        To ABB GMD SB/GEN(SB)/840     0                                       100                                               0                                                                26505.00
                                                                  
8  08 Sep 2012        To SI TD/RD/89                                                        8000                                              0                                                                18505.00
                                                                  
9  14 Sep 2012        By Cash                       0                                       0                                                 14640                                                            33145.00
                                                                  
10 15 Sep 2012        To Cash                       0                                       10000                                             0                                                                23145.00
                                                                  
11 30 Sep 2012        By Half Yearly Interest                                               0                                                 1397                                                             24542.00
                                                                  
12 05 Oct 2012        To Cash                       0                                       4000                                              0                                                                20542.00
                                                                  
13 05 Oct 2012        By Cash                       0                                       0                                                 13582                                                            34124.00


Image link

[IMG]http://i57.tinypic.com/x6bu5w.jpg[/IMG]

Please tell me what wrong here
Posted
Updated 19-Sep-14 0:52am
v4
Comments
Richard MacCutchan 18-Sep-14 5:49am    
I'm not sure which format command matches which part of your ouptut but my tidy up of your code should help you to see it, or show us which is which.
george4986 18-Sep-14 6:17am    
instead of posting 'co.ToString(),per1,ds.Tables[0].Rows[i][3].ToString()' post there values like 'value' on their corresponding fields will improve ur question.
Black_Rose 18-Sep-14 7:56am    
I updated with my sample data
george4986 19-Sep-14 0:05am    
whats the value of d ,d1?
george4986 19-Sep-14 0:13am    
debug ur code ,use break point

run code like below providing values directly

string strline = string.Format("{0,-3}", "1") +
String.Format("{0,-19:dd MMM yyyy}", " 07 Aug 2012") +
string.Format("{0,-30}", "By IB-2012220152498-cash") +
string.Format("{0,-40}", "0") +
string.Format("{0,-50}", "0") +
Math.Round(0.0, 2) +
string.Format("{0,-60}", "10938") +
Math.Round(0.0, 2) +
string.Format("{0,-80}","44929.00");

after passing this line view value of strline .
change code to match ur desired output,make a single line correct then use the loop .good luck

1 solution

You have to put Math.Round(d1, 2) into String.Format too:
C#
String.Format("{0, -70}", math.round(d1,2))


Same for d except with -55 (or whatever)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900