/// <summary> /// used internally to Set the properties given a Sheet object /// </summary> /// <param name="sheet">The sheet.</param> private void SetPropertiesFromSheet(Sheet sheet) { RowRecord row = sheet.NextRow; bool rowRecordsAlreadyPresent = row != null; while (row != null) { CreateRowFromRecord(row); row = sheet.NextRow; } CellValueRecordInterface[] cvals = sheet.GetValueRecords(); long timestart = DateTime.Now.Millisecond; if (log.Check(POILogger.DEBUG)) log.Log(DEBUG, "Time at start of cell creating in HSSF sheet = ", timestart); HSSFRow lastrow = null; // Add every cell to its row for (int i = 0; i < cvals.Length; i++) { CellValueRecordInterface cval = cvals[i]; long cellstart = DateTime.Now.Millisecond; HSSFRow hrow = lastrow; if ((lastrow == null) || (lastrow.RowNum != cval.Row)) { hrow = GetRow(cval.Row); if (hrow == null) { // Some tools (like Perl module SpReadsheet::WriteExcel - bug 41187) skip the RowRecords // Excel, OpenOffice.org and GoogleDocs are all OK with this, so POI should be too. if (rowRecordsAlreadyPresent) { // if at least one row record is present, all should be present. throw new Exception("Unexpected missing row when some rows alReady present"); } // Create the row record on the fly now. RowRecord rowRec = new RowRecord(cval.Row); sheet.AddRow(rowRec); hrow = CreateRowFromRecord(rowRec); } } if (hrow != null) { lastrow = hrow; if (cval is Record) { if (log.Check(POILogger.DEBUG)) log.Log(DEBUG, "record id = " + StringUtil.ToHexString(((Record)cval).Sid)); } hrow.CreateCellFromRecord(cval); if (log.Check(POILogger.DEBUG)) log.Log(DEBUG, "record took ",DateTime.Now.Millisecond - cellstart); } else { cval = null; } } if (log.Check(POILogger.DEBUG)) log.Log(DEBUG, "total sheet cell creation took ", DateTime.Now.Millisecond - timestart); }