aspose file tools*
The moose likes Servlets and the fly likes Formatting in Wordpad Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Formatting in Wordpad" Watch "Formatting in Wordpad" New topic
Author

Formatting in Wordpad

Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Hi,

I have a requirement to export the data which is shown in a Jsp file to some text file.

Here is what i have tried


And the output desired is as:

Is there any better way to do this?

Thanks



[Thumbnail for img.jpeg]



Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

Have you tried tab delimited values. Use the \t escape character. Tab delimited files can also be opened in cell editors (excel like apps) since they are similar to CSV files.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Ya i tried it earlier....but the client had some particular requirement where the the number of space+digit between the end of first column and end of second column be 18.

I.e spaces+digits = 18 for first, 40 for the next ....

so \t fails there......
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

Sumit Patil wrote:Ya i tried it earlier....but the client had some particular requirement where the the number of space+digit between the end of first column and end of second column be 18.

I.e spaces+digits = 18 for first, 40 for the next ....

so \t fails there......


Ask the client why they have this requirement. Who is going to end up using this file ? Can the client reconfigure the font / tab displays in their editor so that it looks like there are 18 spaces between ? Can they use an offline regex tool to replace \t with 18 spaces ?
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296


Ask the client why they have this requirement. Who is going to end up using this file ? Can the client reconfigure the font / tab displays in their editor so that it looks like there are 18 spaces between ? Can they use an offline regex tool to replace \t with 18 spaces ?


Yes i know it is disgusting......but this is what they want and my team lead wants to deliver it.......
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

If you add 18 spaces the way you described earlier, the output will not display in the way wordpad is displaying it. This is because, unless the length of each field is fixed, the output will not look aligned.

You can work around that by calculating the max length of each column in the output. The padding between columns should then be maxColLength(col_num) + 18. A waste of processing power, efficiency and the code will probably be difficult to write / maintain.

If the reason is solely that the formatting in word should look great, its not a good reason to go through so much pain. But then again we do not live in an ideal world. You might have to end up implementing this logic, just because some one wants it
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Deepak Bala wrote:
But then again we do not live in an ideal world. You might have to end up implementing this logic, just because some one wants it

Yes that is what i have done in the addspace method. this is just delivering what the client wants......so developing and maintaining the code......
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Formatting in Wordpad
 
Similar Threads
Writting confirmation message??
Writting confirmation message??
unable to preserve newline
Connection Broken & Check??
Formatting in Notepad