To save to a new directory in a new file after reading the Excel template modification data

Source: Internet
Author: User

To get the template file path:

string " \\xls\\ file name. xls ";    The front "\\xls\\ is the file path", can be as follows: \\Users\\Administrator\\Desktop\\
Hssfworkbook Hssfworkbookdown;   Create an Excel object // read into the Excel file that you just copied usingthenew  FileStream ( Modelexlpath, FileMode.Open, FileAccess.Read))  //path, open permissions, Read permissions {   new  Hssfworkbook ( file);   File. Close ();}
//a page of the template in the Getsheetat method, the first page here is 0Hssfsheet Sheet1 = (hssfsheet) hssfworkbookdown.getsheetat (0); //start writing data to an Excel table//Modify Cell, this is 2nd row 5th columnHssfcell cell = (Hssfcell) Sheet1. GetRow (2). Getcell (5); Here 25 is 3F, which is F3 cell. Setcellvalue (Double.  Parse ("2.5")); Here the set type is double, the value written is 2.5//Modify Cell, this is 2nd row 9th columnCell = (Hssfcell) Sheet1. GetRow (2). Getcell (9); Cell. Setcellvalue (Double. Parse ("2.9"));

Next Save the file:

New" file name. xls";  // file name sfd. Filter = Excel Workbook (*.xls) |*.xls";  File type sfd. ShowDialog (); // Create a file New FileStream (SFD). FileName, FileMode.Create); hssfworkbookdown.write (files);    Files. Close ();

To save to a new directory in a new file after reading the Excel template modification data

Related Article

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.