Sfoglia il codice sorgente

Copy in column definitions from XLSX files, expanding them into one definition
per row as we go. Also exclude definitions for columns outside the dimensions
of the spreadsheet.

Geoffrey J. Teale 11 anni fa
parent
commit
1580d57bdc
1 ha cambiato i file con 13 aggiunte e 4 eliminazioni
  1. 13 4
      lib.go

+ 13 - 4
lib.go

@@ -357,11 +357,20 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File) ([]*Row, []*Col, in
 			Hidden: false,
 			Hidden: false,
 		}
 		}
 	}
 	}
+
+	// Columns can apply to a range, for convenience we expand the
+	// ranges out into individual column definitions.
 	for _, rawcol := range Worksheet.Cols.Col {
 	for _, rawcol := range Worksheet.Cols.Col {
-		cols = append(cols, &Col{
-			Min:    rawcol.Min,
-			Max:    rawcol.Max,
-			Hidden: rawcol.Hidden})
+		// Note, below, that sometimes column definitions can
+		// exist outside the defined dimensions of the
+		// spreadsheet - we deliberately exclude these
+		// columns.
+		for i := rawcol.Min; i <= rawcol.Max && i <= colCount; i++ {
+			cols[i-1] = &Col{
+				Min:    rawcol.Min,
+				Max:    rawcol.Max,
+				Hidden: rawcol.Hidden}
+		}
 	}
 	}
 
 
 	for rowIndex := 0; rowIndex < len(Worksheet.SheetData.Row); rowIndex++ {
 	for rowIndex := 0; rowIndex < len(Worksheet.SheetData.Row); rowIndex++ {