An error is reported when Excel is inserted into big data, and an excel report is reported when data is inserted.

Source: Internet
Author: User

An error is reported when Excel is inserted into big data, and an excel report is reported when data is inserted.

Problems found:

When I recently run the program, I found a problem, that is, when I export the excel file, I reported an error.

Static void Main (string [] args) {IWorkbook wk = new HSSFWorkbook (); ISheet sheet = wk. createSheet ("StudentK"); ISheet sheet2 = wk. createSheet ("TeacherL"); Stopwatch sw = new Stopwatch (); sw. start (); for (int I = 0; I <75535; I ++) {if (I <= 65535) {IRow row = sheet. createRow (I); row. createCell (0 ). setCellValue ("Kimisme"); row. createCell (1 ). setCellValue (I. toString (); row. createCell (2 ). setCellValue (DateTime. now. toString ("s");} else if (I> 65535) {IRow row = sheet2.CreateRow (i-65536); row. createCell (0 ). setCellValue ("Kimisme"); row. createCell (1 ). setCellValue (I. toString (); row. createCell (2 ). setCellValue (DateTime. now. toString ("s") ;}} sw. stop (); Console. writeLine (sw. elapsedMilliseconds); sw. restart (); using (FileStream writer = File. openWrite ("old antique .xls") {wk. write (writer);} Console. writeLine (sw. elapsedMilliseconds); Console. writeLine ("OK"); Console. readKey ();}

Result chart

Static void Main (string [] args) {// There are two changes, this is the first place IWorkbook wk = new XSSFWorkbook (); ISheet sheet = wk. createSheet ("FrientS"); Stopwatch sw = new Stopwatch (); sw. start (); for (int I = 0; I <75535; I ++) {IRow row = sheet. createRow (I); row. createCell (0 ). setCellValue ("Kimisme"); row. createCell (1 ). setCellValue (I. toString (); row. createCell (2 ). setCellValue (DateTime. now. toString ("s");} sw. stop (); Console. writeLine (sw. elapsedMilliseconds); sw. restart (); // This is the second using (FileStream writer = File. openWrite ("new things .xlsx") {wk. write (writer);} Console. writeLine (sw. elapsedMilliseconds); Console. writeLine ("OK"); Console. readKey ();}

Result diagram:

Finally, I would like to express my gratitude for the object-oriented approach and the replacement principle of Lishi for the following reasons:

  • HSSFWorkbook: indicates the operation of excel20031. the extension name is .xls.
  • XSSFWorkbook: it is the worker that operates the excel2007, and the extension name is .xlsx

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.