Explorar o código

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 %!s(int64=11) %!d(string=hai) anos
pai
achega
1580d57bdc
Modificáronse 1 ficheiros con 13 adicións e 4 borrados
  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++ {