Przeglądaj źródła

All tests now passing

Geoffrey J. Teale 12 lat temu
rodzic
commit
e2b3c8977f
2 zmienionych plików z 4 dodań i 5 usunięć
  1. 2 3
      lib.go
  2. 2 2
      lib_test.go

+ 2 - 3
lib.go

@@ -321,9 +321,8 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File) ([]*Row, int, int)
 	rowCount = (maxRow - minRow) + 1
 	colCount = (maxCol - minCol) + 1
 	rows = make([]*Row, rowCount)
-	for rowIndex := 0; rowIndex < len(Worksheet.SheetData.Row); rowIndex++ {
+	for rowIndex := 0; rowIndex < rowCount; rowIndex++ {
 		rawrow := Worksheet.SheetData.Row[rowIndex]
-		fmt.Printf("%s", rowIndex)
 		// range is not empty
 		if len(rawrow.Spans) != 0 {
 			row = makeRowFromSpan(rawrow.Spans)
@@ -338,7 +337,7 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File) ([]*Row, int, int)
 				row.Cells[x].styles = file.styles
 			}
 		}
-		rows[rawrow.R-1] = row
+		rows[rowIndex] = row
 	}
 	return rows, colCount, rowCount
 }

+ 2 - 2
lib_test.go

@@ -593,8 +593,8 @@ func TestReadRowsFromSheetWithLeadingEmptyRows(t *testing.T) {
 	file := new(File)
 	file.referenceTable = MakeSharedStringRefTable(sst)
 	rows, maxCols, maxRows := readRowsFromSheet(worksheet, file)
-	if maxRows != 5 {
-		t.Error("Expected maxRows == 5, got ", strconv.Itoa(len(rows)))
+	if maxRows != 2 {
+		t.Error("Expected maxRows == 2, got ", strconv.Itoa(len(rows)))
 	}
 	if maxCols != 1 {
 		t.Error("Expected maxCols == 1, got ", strconv.Itoa(maxCols))