Save after using POI to modify Excel

Source: Internet
Author: User

Public void writer_excel (String ssheetname,int irow,string scolumn,string data)   {            InputStream is=null;         OutputStream os=null;         iRow=iRow-1;        try{             is=new fileinputstream (file);                     workbook=new  Hssfworkbook (is);             sheet sheet= Workbook.getsheet (Ssheetname);                 int column=excel_returncolumnindex (Sheet,irow,scolumn);              cell cell=sheet.getrow (IRow). Getcell (Column);             system.out.println (Getcellvalue (cell));             cell.setcelltype (cell. cell_type_string);                         cell.setcellvalue (Data);                 os=new fileoutputstream (file);             workbook.write (OS);         }catch (exception e) {             e.printstacktrace ();        }finally{             try {   &nBsp;            os.close ();             } catch  (IOEXCEPTION E1)  {                 // TODO  auto-generated catch block                 e1.printstacktrace ();             }            try {                 is.close ();             } catch  (ioexception e)  {                 // todo  auto-generated catch block                 E.printstacktrace ();            }                          try {                 workbook.close ();             } catch  (ioexception e)  {                 // TODO Auto-generated catch block                 e.printstacktrace ();             }         }    }

Online search for a long time, found that everyone is using POI directly create files, format, font, and write files. However, you always do not see how to modify the file after saving.

According to the way to create a file to modify the file, without saving, the code will only modify the memory of the copy, and will not modify the physical files, you need to write a bit!


The code is as follows:

This is the code that was written. File is a Document object

Os=new fileoutputstream (file); Workbook.write (OS);


Save after using POI to modify Excel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.