똑같은 파일인데 <div>poi로 열었을때 옛날 파일은 안열리고요 이름만 바꾼 똑같은 파일은 열립니다</div> <div>이름도 많이 바꾼거아니고 그냥 글자 하나바꿨어요 ,,, </div> <div>오류는</div> <div>org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0x213C0A0D0A0D0A0D, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document</div> <div><br></div> <div>이렇게 나옵니다 ., 혹시 아시는분 계실까요</div> <div>소스코드는 인터넷에서 돌아다니는거 썼어요.ㅠ</div> <div><br></div> <div><div>package main;</div> <div><br></div> <div>import java.awt.EventQueue;</div> <div>import java.io.FileInputStream;</div> <div><br></div> <div>import javax.swing.JButton;</div> <div>import javax.swing.JFrame;</div> <div>import javax.swing.JPanel;</div> <div>import javax.swing.border.EmptyBorder;</div> <div><br></div> <div>import org.apache.poi.hssf.usermodel.HSSFCell;</div> <div>import org.apache.poi.hssf.usermodel.HSSFRow;</div> <div>import org.apache.poi.hssf.usermodel.HSSFSheet;</div> <div>import org.apache.poi.hssf.usermodel.HSSFWorkbook;</div> <div><br></div> <div>public class frame_test extends JFrame {</div> <div><br></div> <div><span style="white-space:pre;"> </span>private JPanel contentPane;</div> <div><br></div> <div><span style="white-space:pre;"> </span>/**</div> <div><span style="white-space:pre;"> </span> * Launch the application.</div> <div><span style="white-space:pre;"> </span> */</div> <div><span style="white-space:pre;"> </span>public static void main(String[] args) {</div> <div><span style="white-space:pre;"> </span>EventQueue.invokeLater(new Runnable() {</div> <div><span style="white-space:pre;"> </span>@SuppressWarnings("deprecation")</div> <div><span style="white-space:pre;"> </span>public void run() {</div> <div><span style="white-space:pre;"> </span>try {</div> <div><span style="white-space:pre;"> </span>frame_test frame = new frame_test();</div> <div><span style="white-space:pre;"> </span>frame.setVisible(true);</div> <div><span style="white-space:pre;"> </span>FileInputStream fis=new FileInputStream("C:\\Users\\phobi\\Desktop\\산불위험지수 전체DB\\2013\\10월\\2013년 10월 울산.xls");</div> <div><span style="white-space:pre;"> </span>HSSFWorkbook workbook=new HSSFWorkbook(fis);</div> <div><span style="white-space:pre;"> </span>int rowindex=0;</div> <div><span style="white-space:pre;"> </span>int columnindex=0;</div> <div><span style="white-space:pre;"> </span>//시트 수 (첫번째에만 존재하므로 0을 준다)</div> <div><span style="white-space:pre;"> </span>//만약 각 시트를 읽기위해서는 FOR문을 한번더 돌려준다</div> <div><span style="white-space:pre;"> </span>HSSFSheet sheet=workbook.getSheetAt(0);</div> <div><span style="white-space:pre;"> </span>//행의 수</div> <div><span style="white-space:pre;"> </span>int rows=sheet.getPhysicalNumberOfRows();</div> <div><span style="white-space:pre;"> </span>for(rowindex=1;rowindex<rows;rowindex++){</div> <div><span style="white-space:pre;"> </span> //행을 읽는다</div> <div><span style="white-space:pre;"> </span> HSSFRow row=sheet.getRow(rowindex);</div> <div><span style="white-space:pre;"> </span> if(row !=null){</div> <div><span style="white-space:pre;"> </span> <span style="white-space:pre;"> </span>if(rows < 10) continue;</div> <div><span style="white-space:pre;"> </span> //셀의 수</div> <div><span style="white-space:pre;"> </span> int cells=row.getPhysicalNumberOfCells();</div> <div><span style="white-space:pre;"> </span> for(columnindex=0;columnindex<=cells;columnindex++){</div> <div><span style="white-space:pre;"> </span> //셀값을 읽는다</div> <div><span style="white-space:pre;"> </span> HSSFCell cell=row.getCell(columnindex);</div> <div><span style="white-space:pre;"> </span> String value="";</div> <div><span style="white-space:pre;"> </span> //셀이 빈값일경우를 위한 널체크</div> <div><span style="white-space:pre;"> </span> if(cell==null){</div> <div><span style="white-space:pre;"> </span> continue;</div> <div><span style="white-space:pre;"> </span> }else{</div> <div><span style="white-space:pre;"> </span> //타입별로 내용 읽기</div> <div><span style="white-space:pre;"> </span> switch (cell.getCellType()){</div> <div><span style="white-space:pre;"> </span> case HSSFCell.CELL_TYPE_FORMULA:</div> <div><span style="white-space:pre;"> </span> value=cell.getCellFormula();</div> <div><span style="white-space:pre;"> </span> break;</div> <div><span style="white-space:pre;"> </span> case HSSFCell.CELL_TYPE_NUMERIC:</div> <div><span style="white-space:pre;"> </span> value=cell.getNumericCellValue()+"";</div> <div><span style="white-space:pre;"> </span> break;</div> <div><span style="white-space:pre;"> </span> case HSSFCell.CELL_TYPE_STRING:</div> <div><span style="white-space:pre;"> </span> value=cell.getStringCellValue()+"";</div> <div><span style="white-space:pre;"> </span> break;</div> <div><span style="white-space:pre;"> </span> case HSSFCell.CELL_TYPE_BLANK:</div> <div><span style="white-space:pre;"> </span> value=cell.getBooleanCellValue()+"";</div> <div><span style="white-space:pre;"> </span> break;</div> <div><span style="white-space:pre;"> </span> case HSSFCell.CELL_TYPE_ERROR:</div> <div><span style="white-space:pre;"> </span> value=cell.getErrorCellValue()+"";</div> <div><span style="white-space:pre;"> </span> break;</div> <div><span style="white-space:pre;"> </span> }</div> <div><span style="white-space:pre;"> </span> }</div> <div><span style="white-space:pre;"> </span> System.out.println("각 셀 내용 :"+value);</div> <div><span style="white-space:pre;"> </span> }</div> <div><span style="white-space:pre;"> </span> }</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>} catch (Exception e) {</div> <div><span style="white-space:pre;"> </span>e.printStackTrace();</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>}</div> <div><span style="white-space:pre;"> </span>});</div> <div><span style="white-space:pre;"> </span>}</div> <div><br></div> <div><span style="white-space:pre;"> </span>/**</div> <div><span style="white-space:pre;"> </span> * Create the frame.</div> <div><span style="white-space:pre;"> </span> */</div> <div><span style="white-space:pre;"> </span>public frame_test() {</div> <div><span style="white-space:pre;"> </span>setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</div> <div><span style="white-space:pre;"> </span>setBounds(100, 100, 318, 195);</div> <div><span style="white-space:pre;"> </span>contentPane = new JPanel();</div> <div><span style="white-space:pre;"> </span>contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));</div> <div><span style="white-space:pre;"> </span>setContentPane(contentPane);</div> <div><span style="white-space:pre;"> </span>contentPane.setLayout(null);</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>JButton btnNewButton = new JButton("\uD30C\uC77C \uCC3E\uAE30");</div> <div><span style="white-space:pre;"> </span>btnNewButton.setBounds(12, 27, 97, 23);</div> <div><span style="white-space:pre;"> </span>contentPane.add(btnNewButton);</div> <div><span style="white-space:pre;"> </span>}</div> <div>}</div></div> <div><br></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.