tags:

views:

373

answers:

2

Hai I have an application in which I have a JTable with line breaks(pressing Enter key while editing) included in each and every cell.The problem is when I copy the contents from my JTable to Excel I am not getting the contents in same format as in my Jtable(with line breaks) to my excel that is with line breaks.Is there any way to solve my problem.I have to get the contents from my jtable to excel in the same format with line breaks.

Thank You Chaithu

A: 

How are you copying the contents? Are you using the build in copy support?(ie select all contents and copy w/ ctrl-c), or did you write something yourself to do the copy and paste?

You may have to do the latter, and make sure that you insert the necessary line break characters in to the text.

broschb
No,I am using copy funtionality as which is shown in the below link to copy table data to excelhttp://www.javaworld.com/javaworld/javatips/jw-javatip77.html?page=1
chaithu
A: 

I don't know much about DnD. I think that typically you use a delimiter for each cell data (like comma or tab) and then a newline for each row of data.

So if your cell data contains newline characters you would probably need to wrap the cell data in "...". This would mean you need to write a custom TransferHandler for the table. The old TableTransferHandler from the JDK5 tutorial might help you get started.

camickr
Thanks for ur reply.yes, I have taken tab as delimiter for celldata and newline for row data.How to wrap the cell data?
chaithu
Thanks for ur reply i have wap the cell data with in " " and i got a box symbol in my excel.how can i replace that box symbol.?
chaithu
Create an example in Excell that contains a new line. Then export that to a file. Look at the source of the file to see how excel handle the new line. Then duplicate that in your code.
camickr
Thanks for ur reply I have tried to create a excel with new line in cells and copied that to a wordpad,but i cant find any special symbols in my wordpad.how to see the source of a file? file means is it wordpad file of excel file?Please help me solve this problem.if possible with a sample code.
chaithu
please any one help me to solve this problem
chaithu