ciao a tutti!!!!
riesco in java ad aprire il file docx...questo è il cod.
in questo modo mi aggiunge il testo a JTextArea....ma nel file text.docx ho alcune lettere in maiuscolo ed alcune in grassetto....ma quando lo apro in JTextArea me lo apre con testo normali....come faccio ad aprirlo uguale????codice:import java.io.FileInputStream; import java.io.InputStream; import javax.swing.*; import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.usermodel.XWPFDocument; public class Test { public static void main(String[] args) { JTextArea textArea = new JTextArea(20,30); JFrame frame = new JFrame("Prova"); JPanel p = new JPanel(); p.add(textArea); frame.setSize(700,600); frame.getContentPane().add(p); frame.setVisible(true); try { InputStream in = new FileInputStream("C://text.docx"); XWPFDocument docIn = new XWPFDocument(in); XWPFWordExtractor extractor = new XWPFWordExtractor(docIn); //String docText = extractor.getText(); textArea.append(extractor.getText()); } catch (Exception e) { System.out.println("..."); } } }![]()
![]()

Rispondi quotando
