Ver código fonte

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 anos atrás
pai
commit
1580d57bdc
1 arquivos alterados com 13 adições e 4 exclusões
  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++ {