I read the excel file using the Apache POI library. The contents of the file are displayed on the console. Is it possible to display the contents not on the console, but in a separate window (for example, using the javax.swing library)?
Very confused while trying to do something.
Thanks in advance for your help.
Part 1 - reading excel
public class Readsheet{ static XSSFRow row; public static void main(String[] args) throws Exception{ FileInputStream fis = new FileInputStream(new File("1_2016_September.xlsx")); XSSFWorkbook workbook = new XSSFWorkbook(fis); XSSFSheet spreadsheet = workbook.getSheetAt(0); Iterator < Row > rowIterator = spreadsheet.iterator(); while (rowIterator.hasNext()){ row = (XSSFRow) rowIterator.next(); Iterator < Cell > cellIterator = row.cellIterator(); while (cellIterator.hasNext()){ Cell cell = cellIterator.next(); switch (cell.getCellType()){ case Cell.CELL_TYPE_NUMERIC: System.out.print(cell.getNumericCellValue() + " \t" ); break; case Cell.CELL_TYPE_STRING: System.out.print(cell.getStringCellValue() + " \t" ); break; } } System.out.println(); CompletedWorks History = new CompletedWorks(); //? History.displayFieldHistory.setText(???); //? } fis.close(); } } Part 2 is a window
public class CompletedWorks { JPanel panelComplitedWorks; JPanel pTop; JPanel pCenter; JLabel thisDay; JCheckBox paidCheck; public JTextArea displayFieldHistory; //? public CompletedWorks (){ panelComplitedWorks= new JPanel(); BorderLayout panelCW = new BorderLayout(1,1); panelComplitedWorks.setLayout(panelCW); displayFieldHistory = new JTextArea(10, 10); displayFieldHistory.setLineWrap(true); displayFieldHistory.setWrapStyleWord(true); pCenter = new JPanel(); GridLayout glH =new GridLayout(1,1); pCenter.setLayout(glH); pCenter.add(displayFieldHistory); panelComplitedWorks.add("Center",pCenter); thisDay = new JLabel("Date"); paidCheck = new JCheckBox("salary"); pTop = new JPanel(); GridLayout gl2 =new GridLayout(1,2); pTop.setLayout(gl2); pTop.add(thisDay); pTop.add(paidCheck); panelComplitedWorks.add("North",pTop); JFrame frameHistory = new JFrame("A list of completed orders"); frameHistory.setContentPane(panelComplitedWorks); frameHistory.pack(); frameHistory.setLocation(500, 205); frameHistory.setVisible(true); } public static void main(String[] args) { CompletedWorks CW = new CompletedWorks(); } }