|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Writing Data In Tabular format in Text File.i want to write some data in tabular format in text file. i've data in strings and i want to write like this in file col1 col2 col3 d1 d1 d1 d2 d2 d2 d3 d3 d3 the problem is, i dont know how can i maintain spaces between the columns as i dont know which column will have what length of text. in c++, i think u can do by adding padding to make sure the alignment remains correctly but i dont know how can i do that in c#. i would appriciate your help, thanks Lucky Hi lucky,
Unfortunately, I think you should: A. Try to find out what the maximum length is of a single cell in all columns, and add enough whitespace to the other cells while writing to the text file. or B. Start with a single whitespace, and each time you encounter a cell that would require a previous cell in the column to have more whitespace, to go back and review all cells in the column (and give them more whitespaces). Of course, option B is far more expensive, so you should really try to know beforehand. I guess this is just a limitation of the constraints you pose (use txt file and use whitespace). Btw it feels like txt is perhaps not your best option here? Can't you save in html and use tables or use a comma-delimited file? Anyway, hope this helps. Regards, Jeroen lucky schreef: Show quoteHide quote > Hi guys, > i want to write some data in tabular format in text file. i've data in > strings and i want to write like this in file > > col1 col2 col3 > > d1 d1 d1 > d2 d2 d2 > d3 d3 d3 > > the problem is, i dont know how can i maintain spaces between the > columns as i dont know which column will have what length of text. > > in c++, i think u can do by adding padding to make sure the alignment > remains correctly but i dont know how can i do that in c#. > > i would appriciate your help, > > thanks > Lucky hey pal,
thanks for replay. i'm thinking about the first option from the begining but i wanted to take a chance to ask you people if someone knows some other way of doing. the reason why i can't use html or csv file is, i'm write data into the log file and this file has different kind of data. The data that i need to write is just a small part of it. that is why i didnt want to write a long code to find the lenght of data and then format ir. but it seems. i dont have another way.. thanks anyways, Lucky Jeroen wrote: Show quoteHide quote > Hi lucky, > > Unfortunately, I think you should: > > A. Try to find out what the maximum length is of a single cell in all > columns, and add enough whitespace to the other cells while writing to > the text file. > > or > > B. Start with a single whitespace, and each time you encounter a cell > that would require a previous cell in the column to have more > whitespace, to go back and review all cells in the column (and give > them more whitespaces). > > Of course, option B is far more expensive, so you should really try to > know beforehand. I guess this is just a limitation of the constraints > you pose (use txt file and use whitespace). > > Btw it feels like txt is perhaps not your best option here? Can't you > save in html and use tables or use a comma-delimited file? > > Anyway, hope this helps. > > Regards, > Jeroen > > > lucky schreef: > > > Hi guys, > > i want to write some data in tabular format in text file. i've data in > > strings and i want to write like this in file > > > > col1 col2 col3 > > > > d1 d1 d1 > > d2 d2 d2 > > d3 d3 d3 > > > > the problem is, i dont know how can i maintain spaces between the > > columns as i dont know which column will have what length of text. > > > > in c++, i think u can do by adding padding to make sure the alignment > > remains correctly but i dont know how can i do that in c#. > > > > i would appriciate your help, > > > > thanks > > Lucky Lucky wrote:
Show quoteHide quote > hey pal, Erm.. put tabs between the columns? (vbTab)> thanks for replay. i'm thinking about the first option from the > begining but i wanted to take a chance to ask you people if someone > knows some other way of doing. > > the reason why i can't use html or csv file is, i'm write data into the > log file and this file has different kind of data. The data that i need > to write is just a small part of it. that is why i didnt want to write > a long code to find the lenght of data and then format ir. but it > seems. i dont have another way.. > > thanks anyways, > Lucky > > Jeroen wrote: > >>Hi lucky, >> >>Unfortunately, I think you should: >> >>A. Try to find out what the maximum length is of a single cell in all >>columns, and add enough whitespace to the other cells while writing to >>the text file. >> >>or >> >>B. Start with a single whitespace, and each time you encounter a cell >>that would require a previous cell in the column to have more >>whitespace, to go back and review all cells in the column (and give >>them more whitespaces). >> >>Of course, option B is far more expensive, so you should really try to >>know beforehand. I guess this is just a limitation of the constraints >>you pose (use txt file and use whitespace). >> >>Btw it feels like txt is perhaps not your best option here? Can't you >>save in html and use tables or use a comma-delimited file? >> >>Anyway, hope this helps. >> >>Regards, >>Jeroen >> >> >>lucky schreef: >> >> >>>Hi guys, >>>i want to write some data in tabular format in text file. i've data in >>>strings and i want to write like this in file >>> >>>col1 col2 col3 >>> >>>d1 d1 d1 >>>d2 d2 d2 >>>d3 d3 d3 >>> >>>the problem is, i dont know how can i maintain spaces between the >>>columns as i dont know which column will have what length of text. >>> >>>in c++, i think u can do by adding padding to make sure the alignment >>>remains correctly but i dont know how can i do that in c#. >>> >>>i would appriciate your help, >>> >>>thanks >>>Lucky > > -- Rinze van Huizen C-Services Holland b.v
how do you use Class to hold global variables?
VB.NET Datagrid with pictures VB equivalent of this C# code Why no patch for the anoying Visual Basic compiler problem What framework is running in this scenario? Not CLS-compliant warning... Help understanding user created Delegates Arrow on a button control User controls in VS 2005 .NET FrameWork 1.1 Winform DataGrid |
|||||||||||||||||||||||