Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7847285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:50:54+00:00 2026-06-02T17:50:54+00:00

I use the code that you can see below in order to strike through

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:50:55+00:00Added an answer on June 2, 2026 at 5:50 pm

    The JAVA code:

    String striked=("<html><strike>".concat(tostrike).concat("</strike>       </html>"));
    jTable.setValueAt(striked, i, j);
    

    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

    import java.io.File;
    import jxl.Workbook;
    import jxl.write.Label;
    import jxl.write.WritableCell;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableFont;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;
    
    public class ExcelCreate {
    
      public static void main(String[] args) {
        try {
    
             WritableWorkbook workbook =
             Workbook.createWorkbook(new File("output.xls"));
             WritableSheet sheet = workbook.createSheet("Page1", 0);
    
             String Label[] = new String[4];
             Label[0] = "Emp ID";
             Label[1] = "Name";
             Label[2] = "Department";
             Label[3] = "Designation";
    
             WritableCellFormat cellFormat = new WritableCellFormat();
             WritableFont font = new WritableFont(WritableFont.ARIAL);
             font.setStruckout(true);
             cellFormat.setFont(font);
    
             for (int i = 0; i < Label.length; i++) {
                 Label label = new Label(i, 0, Label[i]);
                 sheet.addCell(label);
                 WritableCell cell = sheet.getWritableCell(i, 0);
                 cell.setCellFormat(cellFormat);
             }
    
             workbook.write();
             workbook.close();
    
        } catch (Exception e) {
            /* Write your logic to handle exception. 
             */
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an ide/site that I can use to analyse code below and get
How can I use JUnit idiomatically to test that some code throws an exception?
I assume that you can't use a JavaScript code snippet to validate if the
I'm switching our ASP code to use SQL Native Client so that we can
Is there any magic tools i can use to scan source code that was
How can I take the YouTube embedded code that YouTube provides and use a
I want to use regions for code folding in Eclipse ; how can that
In my code, is there a shorthand that I can use to assign a
I'm trying to use PyLucene, and I can't find any code examples that actually
I have a console application that require to use some code that need administrator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.