Home > Net > Written in NPOI to an existing EXCEL file data, how to operate to the original data are not covered,
Written in NPOI to an existing EXCEL file data, how to operate to the original data are not covered,
Time:09-19
I write data in NPOI to existing EXCEL, EXCEL A1 cell data originally, want to on the basis of writing new data in the A2 cell, use the following code found A1 cell disappeared, excuse me how to operate to get A1 A2 data at the same time?
HSSFWorkbook workbook=new HSSFWorkbook ();//XLS format ISheet sheet=workbook. CreateSheet (); IRow row=sheet. CreateRow (0);//from the first line wrote Row. CreateCell (1, CellType. Numeric). SetCellValue (3.14); Using (FileStream stream=new FileStream (@ "C: \ test1. XLS", FileMode. OpenOrCreate, FileAccess. ReadWrite)) { Workbook. Write (stream); The Dispose (); }
CodePudding user response:
IRow row=sheet. CreateRow (0) Into a sheet. GetRow (0) line Of course, first to determine whether the number of lines & gt;=1