I use the code that you can see below in order to strike through some cells in a jtable. Works great for me, and both in appearence and in print with JTable.print() method works excellent.
public void strikeThrough()
{
int rows=jTable.getRowCount();
destroiedDocs=new ArrayList<>();
for (int i = 0; i < rows; i++)
{
String test=String.valueOf(jTable.getValueAt(i,5));
if (test.equals("K"))
{
for (int j = 1; j < 5; j++)
{
String tostrike= String.valueOf(jTable.getValueAt(i, j));
String striked=("<html><strike>".concat(tostrike).concat("</strike> </html>"));
jTable.setValueAt(striked, i, j);
destroiedDocs.add(i);
}
}
}
}
The problem is that when I export the resaults to excel with the jxl class I got the value in these strike through cells with the appearence
<html><strike>some text</strike></html>
instead of some text in strikethrough.
Any recomandations on how to solve this formating problem?
I pass the cells in the excel cell by cell from the jtable with loops.
Thank you!
The JAVA code:
Will work only for JAVA UI. After exporting data to excel it will show original text.
You need to perform following steps:
1. Before exporting remove
<html><strike>and</strike></html>. Keep original text.2. Use following code to strikethrough cell.
Run the following code using
jxl-2.6.10.jar