Преглед изворни кода

Revert "prevent all tabSelected be true / prevent row.cell.V showing up when Value is null / change default celltype to CellTypeGeneral from CellTypeString"

This reverts commit 0a4e650565782cf5805707776138224a79e9e7cd.
blackss2 пре 10 година
родитељ
комит
9dc29a5895
4 измењених фајлова са 12 додато и 20 уклоњено
  1. 4 9
      file.go
  2. 0 1
      row.go
  3. 2 4
      sheet.go
  4. 6 6
      xmlWorksheet.go

+ 4 - 9
file.go

@@ -175,11 +175,8 @@ func (f *File) MarshallParts() (map[string]string, error) {
 		f.styles = newXlsxStyleSheet(f.theme)
 	}
 	f.styles.reset()
-	for i, sheet := range f.Sheets {
+	for _, sheet := range f.Sheets {
 		xSheet := sheet.makeXLSXSheet(refTable, f.styles)
-		if i == 0 {
-			xSheet.SheetViews.SheetView[0].TabSelected = true
-		}
 		rId := fmt.Sprintf("rId%d", sheetIndex)
 		sheetId := strconv.Itoa(sheetIndex)
 		sheetPath := fmt.Sprintf("worksheets/sheet%d.xml", sheetIndex)
@@ -222,11 +219,9 @@ func (f *File) MarshallParts() (map[string]string, error) {
 	parts["xl/theme/theme1.xml"] = TEMPLATE_XL_THEME_THEME
 
 	xSST := refTable.makeXLSXSST()
-	if xSST.Count > 0 || xSST.UniqueCount > 0 {
-		parts["xl/sharedStrings.xml"], err = marshal(xSST)
-		if err != nil {
-			return parts, err
-		}		
+	parts["xl/sharedStrings.xml"], err = marshal(xSST)
+	if err != nil {
+		return parts, err
 	}
 
 	xWRel := workbookRels.MakeXLSXWorkbookRels()

+ 0 - 1
row.go

@@ -15,7 +15,6 @@ func (r *Row) SetHeightCM(ht float64) {
 
 func (r *Row) AddCell() *Cell {
 	cell := NewCell(r)
-	cell.cellType = CellTypeGeneral
 	r.Cells = append(r.Cells, cell)
 	r.Sheet.maybeAddCol(len(r.Cells))
 	return cell

+ 2 - 4
sheet.go

@@ -166,9 +166,7 @@ func (s *Sheet) makeXLSXSheet(refTable *RefTable, styles *xlsxStyleSheet) *xlsxW
 			xC.R = fmt.Sprintf("%s%d", numericToLetters(c), r+1)
 			switch cell.cellType {
 			case CellTypeString:
-				if len(cell.Value) > 0 {
-					xC.V = strconv.Itoa(refTable.AddString(cell.Value))
-				}
+				xC.V = strconv.Itoa(refTable.AddString(cell.Value))
 				xC.T = "s"
 				xC.S = XfId
 			case CellTypeBool:
@@ -195,7 +193,7 @@ func (s *Sheet) makeXLSXSheet(refTable *RefTable, styles *xlsxStyleSheet) *xlsxW
 				xC.S = XfId
 			}
 			xRow.C = append(xRow.C, xC)
-			
+
 			if cell.HMerge > 0 || cell.VMerge > 0 {
 				// r == rownum, c == colnum
 				mc := xlsxMergeCell{}

+ 6 - 6
xmlWorksheet.go

@@ -125,7 +125,7 @@ type xlsxSheetView struct {
 	ShowRowColHeaders       bool            `xml:"showRowColHeaders,attr"`
 	ShowZeros               bool            `xml:"showZeros,attr"`
 	RightToLeft             bool            `xml:"rightToLeft,attr"`
-	TabSelected             bool            `xml:"tabSelected,attr,omitempty"`
+	TabSelected             bool            `xml:"tabSelected,attr"`
 	ShowOutlineSymbols      bool            `xml:"showOutlineSymbols,attr"`
 	DefaultGridColor        bool            `xml:"defaultGridColor,attr"`
 	View                    string          `xml:"view,attr"`
@@ -192,11 +192,11 @@ type xlsxCols struct {
 // currently I have not checked it for completeness - it does as much
 // as I need.
 type xlsxCol struct {
-	Collapsed bool    `xml:"collapsed,attr,omitempty"`
-	Hidden    bool    `xml:"hidden,attr,omitempty"`
+	Collapsed bool    `xml:"collapsed,attr"`
+	Hidden    bool    `xml:"hidden,attr"`
 	Max       int     `xml:"max,attr"`
 	Min       int     `xml:"min,attr"`
-	Style     int     `xml:"style,attr,omitempty"`
+	Style     int     `xml:"style,attr"`
 	Width     float64 `xml:"width,attr"`
 }
 
@@ -248,7 +248,7 @@ type xlsxC struct {
 	R string `xml:"r,attr"`           // Cell ID, e.g. A1
 	S int    `xml:"s,attr,omitempty"` // Style reference.
 	T string `xml:"t,attr,omitempty"` // Type.
-	V string `xml:"v,omitempty"`      // Value
+	V string `xml:"v"`                // Value
 	F *xlsxF `xml:"f,omitempty"`      // Formula
 }
 
@@ -281,7 +281,7 @@ func newXlsxWorksheet() (worksheet *xlsxWorksheet) {
 		ShowOutlineSymbols:      true,
 		ShowRowColHeaders:       true,
 		ShowZeros:               true,
-		TabSelected:             false,
+		TabSelected:             true,
 		TopLeftCell:             "A1",
 		View:                    "normal",
 		WindowProtection:        false,