summaryrefslogtreecommitdiff
path: root/stream.go
diff options
context:
space:
mode:
Diffstat (limited to 'stream.go')
-rw-r--r--stream.go94
1 files changed, 46 insertions, 48 deletions
diff --git a/stream.go b/stream.go
index 52e65a4..91ae78a 100644
--- a/stream.go
+++ b/stream.go
@@ -47,49 +47,48 @@ type StreamWriter struct {
// example, set data for worksheet of size 102400 rows x 50 columns with
// numbers and style:
//
-// file := excelize.NewFile()
-// streamWriter, err := file.NewStreamWriter("Sheet1")
-// if err != nil {
-// fmt.Println(err)
-// }
-// styleID, err := file.NewStyle(&excelize.Style{Font: &excelize.Font{Color: "#777777"}})
-// if err != nil {
-// fmt.Println(err)
-// }
-// if err := streamWriter.SetRow("A1", []interface{}{excelize.Cell{StyleID: styleID, Value: "Data"}},
-// excelize.RowOpts{Height: 45, Hidden: false}); err != nil {
-// fmt.Println(err)
-// }
-// for rowID := 2; rowID <= 102400; rowID++ {
-// row := make([]interface{}, 50)
-// for colID := 0; colID < 50; colID++ {
-// row[colID] = rand.Intn(640000)
-// }
-// cell, _ := excelize.CoordinatesToCellName(1, rowID)
-// if err := streamWriter.SetRow(cell, row); err != nil {
-// fmt.Println(err)
-// }
-// }
-// if err := streamWriter.Flush(); err != nil {
-// fmt.Println(err)
-// }
-// if err := file.SaveAs("Book1.xlsx"); err != nil {
-// fmt.Println(err)
-// }
+// file := excelize.NewFile()
+// streamWriter, err := file.NewStreamWriter("Sheet1")
+// if err != nil {
+// fmt.Println(err)
+// }
+// styleID, err := file.NewStyle(&excelize.Style{Font: &excelize.Font{Color: "#777777"}})
+// if err != nil {
+// fmt.Println(err)
+// }
+// if err := streamWriter.SetRow("A1", []interface{}{excelize.Cell{StyleID: styleID, Value: "Data"}},
+// excelize.RowOpts{Height: 45, Hidden: false}); err != nil {
+// fmt.Println(err)
+// }
+// for rowID := 2; rowID <= 102400; rowID++ {
+// row := make([]interface{}, 50)
+// for colID := 0; colID < 50; colID++ {
+// row[colID] = rand.Intn(640000)
+// }
+// cell, _ := excelize.CoordinatesToCellName(1, rowID)
+// if err := streamWriter.SetRow(cell, row); err != nil {
+// fmt.Println(err)
+// }
+// }
+// if err := streamWriter.Flush(); err != nil {
+// fmt.Println(err)
+// }
+// if err := file.SaveAs("Book1.xlsx"); err != nil {
+// fmt.Println(err)
+// }
//
// Set cell value and cell formula for a worksheet with stream writer:
//
-// err := streamWriter.SetRow("A1", []interface{}{
-// excelize.Cell{Value: 1},
-// excelize.Cell{Value: 2},
-// excelize.Cell{Formula: "SUM(A1,B1)"}});
+// err := streamWriter.SetRow("A1", []interface{}{
+// excelize.Cell{Value: 1},
+// excelize.Cell{Value: 2},
+// excelize.Cell{Formula: "SUM(A1,B1)"}});
//
// Set cell value and rows style for a worksheet with stream writer:
//
-// err := streamWriter.SetRow("A1", []interface{}{
-// excelize.Cell{Value: 1}},
-// excelize.RowOpts{StyleID: styleID, Height: 20, Hidden: false});
-//
+// err := streamWriter.SetRow("A1", []interface{}{
+// excelize.Cell{Value: 1}},
+// excelize.RowOpts{StyleID: styleID, Height: 20, Hidden: false});
func (f *File) NewStreamWriter(sheet string) (*StreamWriter, error) {
sheetID := f.getSheetID(sheet)
if sheetID == -1 {
@@ -120,18 +119,18 @@ func (f *File) NewStreamWriter(sheet string) (*StreamWriter, error) {
// AddTable creates an Excel table for the StreamWriter using the given
// coordinate area and format set. For example, create a table of A1:D5:
//
-// err := sw.AddTable("A1", "D5", "")
+// err := sw.AddTable("A1", "D5", "")
//
// Create a table of F2:H6 with format set:
//
-// err := sw.AddTable("F2", "H6", `{
-// "table_name": "table",
-// "table_style": "TableStyleMedium2",
-// "show_first_column": true,
-// "show_last_column": true,
-// "show_row_stripes": false,
-// "show_column_stripes": true
-// }`)
+// err := sw.AddTable("F2", "H6", `{
+// "table_name": "table",
+// "table_style": "TableStyleMedium2",
+// "show_first_column": true,
+// "show_last_column": true,
+// "show_row_stripes": false,
+// "show_column_stripes": true
+// }`)
//
// Note that the table must be at least two lines including the header. The
// header cells must contain strings and must be unique.
@@ -384,8 +383,7 @@ func marshalRowAttrs(opts ...RowOpts) (attrs string, err error) {
// the 'SetColWidth' function before the 'SetRow' function. For example set
// the width column B:C as 20:
//
-// err := streamWriter.SetColWidth(2, 3, 20)
-//
+// err := streamWriter.SetColWidth(2, 3, 20)
func (sw *StreamWriter) SetColWidth(min, max int, width float64) error {
if sw.sheetWritten {
return ErrStreamSetColWidth