I have been working in a Swing application.In one of the forms I need to select a excel file in JFileChooser and copy it to JTextPane
with proper alignment. I could select it and append it to JTextPane, but with no proper alignment.
Also If I align the text copied from a excel file in JTextPane, I could not get what I have aligned manually in jasper report/ireport.
Why can't I get the JTextPane content aligned properly?
Because of the font. Most fonts are not mono-spaces, meaning some characters (like i or l) take up less space than others (like W or M). Change your font to something like Courier (New) and try again. Or, and this is what I would do, use a JTable.