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