Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 05284ea

Browse files
authored
Merge pull request #555 from tealeg/remove-stream-file-builder
Remove stream file builder
2 parents 5ddd07b + 1df31ef commit 05284ea

13 files changed

+36
-3026
lines changed

cell.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -479,28 +479,3 @@ func (c *Cell) FormattedValue() (string, error) {
479479
func (c *Cell) SetDataValidation(dd *xlsxDataValidation) {
480480
c.DataValidation = dd
481481
}
482-
483-
// StreamingCellMetadata represents anything attributable to a cell
484-
// except for the cell data itself. For example, it is used
485-
// in StreamFileBuilder.AddSheetWithDefaultColumnMetadata to
486-
// associate default attributes for cells in a particular column
487-
type StreamingCellMetadata struct {
488-
cellType CellType
489-
streamStyle StreamStyle
490-
}
491-
492-
var (
493-
DefaultStringStreamingCellMetadata StreamingCellMetadata
494-
DefaultNumericStreamingCellMetadata StreamingCellMetadata
495-
DefaultDecimalStreamingCellMetadata StreamingCellMetadata
496-
DefaultIntegerStreamingCellMetadata StreamingCellMetadata
497-
DefaultDateStreamingCellMetadata StreamingCellMetadata
498-
)
499-
500-
func MakeStreamingCellMetadata(cellType CellType, streamStyle StreamStyle) StreamingCellMetadata {
501-
return StreamingCellMetadata{cellType, streamStyle}
502-
}
503-
504-
func (cm StreamingCellMetadata) Ptr() *StreamingCellMetadata {
505-
return &cm
506-
}

file.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ func (f *File) MarshallParts(zipWriter *zip.Writer) error {
463463
Name: sheet.Name,
464464
SheetId: sheetId,
465465
Id: rId,
466-
State: "visible"}
466+
State: sheet.getState()}
467+
467468
w, err := zipWriter.Create(partName)
468469
if err != nil {
469470
return wrap(err)

file_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,6 @@ func TestFile(t *testing.T) {
896896
c.Assert(len(parts), qt.Equals, 13)
897897
})
898898

899-
900899
csRunO(c, "TestMarshalFileWithHiddenSheet", func(c *qt.C, option FileOption) {
901900
var f *File
902901
f = NewFile(option)
@@ -905,16 +904,21 @@ func TestFile(t *testing.T) {
905904
cell1 := row1.AddCell()
906905
cell1.SetString("A cell!")
907906
sheetHidden, _ := f.AddSheet("SomeHiddenSheet")
908-
sheetHidden.Hidden=true
907+
sheetHidden.Hidden = true
909908
row2 := sheetHidden.AddRow()
910909
cell2 := row2.AddCell()
911910
cell2.SetString("A cell!")
912-
parts, err := f.MarshallParts()
911+
912+
path := filepath.Join(c.Mkdir(), "test.xlsx")
913+
err := f.Save(path)
913914
c.Assert(err, qt.IsNil)
914-
c.Assert(len(parts), qt.Equals, 11)
915-
expectedWorkbook := `<?xml version="1.0" encoding="UTF-8"?>
916-
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion appName="Go XLSX"></fileVersion><workbookPr showObjects="all" date1904="false"></workbookPr><workbookProtection></workbookProtection><bookViews><workbookView showHorizontalScroll="true" showVerticalScroll="true" showSheetTabs="true" tabRatio="204" windowHeight="8192" windowWidth="16384" xWindow="0" yWindow="0"></workbookView></bookViews><sheets><sheet name="MySheet" sheetId="1" r:id="rId1" state="visible"></sheet><sheet name="SomeHiddenSheet" sheetId="2" r:id="rId2" state="hidden"></sheet></sheets><definedNames></definedNames><calcPr iterateCount="100" refMode="A1" iterateDelta="0.001"></calcPr></workbook>`
917-
c.Assert(parts["xl/workbook.xml"], qt.Equals, expectedWorkbook)
915+
916+
xlsxFile, err := OpenFile(path, option)
917+
c.Assert(err, qt.IsNil)
918+
919+
s, ok := xlsxFile.Sheet["SomeHiddenSheet"]
920+
c.Assert(ok, qt.Equals, true)
921+
c.Assert(s.Hidden, qt.Equals, true)
918922
})
919923

920924
// We can save a File as a valid XLSX file at a given path.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module github.com/tealeg/xlsx/v2
1+
module github.com/tealeg/xlsx/v3
22

3-
go 1.12
3+
go 1.14
44

55
require (
66
github.com/frankban/quicktest v1.5.0

lib.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ func getMaxMinFromDimensionRef(ref string) (minx, miny, maxx, maxy int, err erro
240240
// calculateMaxMinFromWorkSheet works out the dimensions of a spreadsheet
241241
// that doesn't have a DimensionRef set. The only case currently
242242
// known where this is true is with XLSX exported from Google Docs.
243-
// This is also true for XLSX files created through the streaming APIs.
244243
func calculateMaxMinFromWorksheet(worksheet *xlsxWorksheet) (minx, miny, maxx, maxy int, err error) {
245244
// Note, this method could be very slow for large spreadsheets.
246245
var x, y int

sheet.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ import (
1313
// Sheet is a high level structure intended to provide user access to
1414
// the contents of a particular sheet within an XLSX file.
1515
type Sheet struct {
16-
Name string
17-
File *File
18-
Cols *ColStore
19-
MaxRow int
20-
MaxCol int
21-
Hidden bool
22-
Selected bool
23-
SheetViews []SheetView
24-
SheetFormat SheetFormat
25-
AutoFilter *AutoFilter
26-
Relations []Relation
27-
DataValidations []*xlsxDataValidation
28-
cellStore CellStore
29-
streamedRowCount int
30-
currentRow *Row
16+
Name string
17+
File *File
18+
Cols *ColStore
19+
MaxRow int
20+
MaxCol int
21+
Hidden bool
22+
Selected bool
23+
SheetViews []SheetView
24+
SheetFormat SheetFormat
25+
AutoFilter *AutoFilter
26+
Relations []Relation
27+
DataValidations []*xlsxDataValidation
28+
cellStore CellStore
29+
currentRow *Row
3130
}
3231

3332
// NewSheet constructs a Sheet with the default CellStore and returns
@@ -58,6 +57,13 @@ func (s *Sheet) Close() {
5857
s.cellStore = nil
5958
}
6059

60+
func (s *Sheet) getState() string {
61+
if s.Hidden {
62+
return "hidden"
63+
}
64+
return "visible"
65+
}
66+
6167
type SheetView struct {
6268
Pane *Pane
6369
}

stream_cell.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)