Go + Excel 学习 Excelize rows.go
Copyright 2016 - 2019 The excelize Authors.
版權所有2016-2019優秀作者。
All rights reserved.
保留所有權利。
Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
此源代碼的使用由可在許可文件中找到的BSD樣式許可管理。
Package excelize providing a set of functions that allow you to write to and read from XLSX files.
包提供了一組函數,允許您對xlsx文件進行寫入和讀取。
Support reads and writes XLSX file generated by Microsoft Excel? 2007 and later.
支持讀取和寫入由Microsoft Excel?2007及更高版本生成的XLSX文件。
Support save file without losing original charts of XLSX.
支持保存文件而不丟失xlsx的原始圖表。
This library needs Go version 1.10 or later.
此庫需要go版本1.10或更高版本。
type Rows struct
Rows defines an iterator to a sheet
行定義工作表的迭代器
type ErrSheetNotExist struct
ErrSheetNotExist defines an error of sheet is not exist
errsheetnotexist定義工作表不存在的錯誤
func (err ErrSheetNotExist) Error() string
func (err ErrSheetNotExist) Error() string {return fmt.Sprintf("Sheet %s is not exist", string(err.SheetName)) }func (rows *Rows) Next() bool
Next will return true if find the next row element.
如果找到下一行元素,next將返回true。
func (rows *Rows) Error() error
Error will return the error when the find next row element
查找下一行元素時,錯誤將返回Error
func convertRowHeightToPixels(height float64) float64
convertRowHeightToPixels provides a function to convert the height of a cell from user’s units to pixels.
convertRowHeightToPixels 提供一個函數,用于將單元格的高度從用戶的單位轉換為像素。
If the height hasn’t been set by the user we use the default value. If the row is hidden it has a value of zero.
如果用戶沒有設置高度,我們使用默認值。如果行被隱藏,則其值為零。
func (f *File) Rows(sheet string) (*Rows, error)
Rows return a rows iterator.
行返回行迭代器。
func (f *File) GetRowHeight(sheet string, row int) (float64, error)
GetRowHeight provides a function to get row height by given worksheet name and row index.
GetRowHeight提供了一個函數,可以根據給定的工作表名稱和行索引獲取行高。
func (f *File) getRowHeight(sheet string, row int) int
getRowHeight provides a function to get row height in pixels by given sheet name and row index.
getRowHeight提供了一個函數,可以通過給定的工作表名稱和行索引以像素為單位獲取行高。
func (f *File) SetRowHeight(sheet string, row int, height float64) error
SetRowHeight provides a function to set the height of a single row.
set row height提供了一個函數來設置單行的高度。
func (f *File) GetRows(sheet string) ([][]string, error)
GetRows return all the rows in a sheet by given worksheet name (case sensitive).
getrows按給定的工作表名稱返回工作表中的所有行(區分大小寫)。
返回一個二維字符串數組和一個錯誤信息。
func (f *File) GetRows(sheet string) ([][]string, error) {rows, err := f.Rows(sheet)if err != nil {return nil, err}results := make([][]string, 0, 64)for rows.Next() {if rows.Error() != nil {break}row, err := rows.Columns()if err != nil {break}results = append(results, row)}return results, nil }func (rows *Rows) Columns() ([]string, error)
Columns return the current row’s column values
列返回當前行的列值
func (f *File) InsertRow(sheet string, row int) error
InsertRow provides a function to insert a new row after given Excel row number starting from 1.
InsertRow提供一個函數,用于在給定的Excel行號(從1開始)之后插入新行。
Use this method with caution, which will affect changes in references such as formulas, charts, and so on.
請謹慎使用此方法,這將影響公式、圖表等引用中的更改。
If there is any referenced value of the worksheet, it will cause a file error when you open it.
如果工作表中有任何引用值,則打開它時將導致文件錯誤。
The excelize only partially updates these references currently.
excelize當前僅部分更新這些引用。
func (f *File) DuplicateRow(sheet string, row int) error
DuplicateRow inserts a copy of specified row (by its Excel row number) below.
duplicateRow在下面插入指定行的副本(按其excel行號)。
Use this method with caution, which will affect changes in references such as formulas, charts, and so on.
請謹慎使用此方法,這將影響公式、圖表等引用中的更改。
If there is any referenced value of the worksheet, it will cause a file error when you open it.
如果工作表中有任何引用值,則打開它時將導致文件錯誤。
The excelize only partially updates these references currently.
excelize當前僅部分更新這些引用。
func (f *File) RemoveRow(sheet string, row int) error
RemoveRow provides a function to remove single row by given worksheet name and Excel row number.
RemoveRow提供了一個按給定工作表名稱和Excel行號刪除單行的函數。
Use this method with caution, which will affect changes in references such as formulas, charts, and so on.
請謹慎使用此方法,這將影響公式、圖表等引用中的更改。
If there is any referenced value of the worksheet, it will cause a file error when you open it.
如果工作表中有任何引用值,則打開它時將導致文件錯誤。
The excelize only partially updates these references currently.
excelize當前僅部分更新這些引用。
func (xlsx *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error)
getValueFrom return a value from a column/row cell, this function is inteded to be used with for range on rows an argument with the xlsx opened file.
getValueFrom從列/行單元格返回一個值,此函數將與xlsx打開文件的參數一起用于行上的范圍。
func (f *File) SetRowVisible(sheet string, row int, visible bool) error
SetRowVisible provides a function to set visible of a single row by given worksheet name and Excel row number.
SetRowVisible 提供了一個函數,用于根據給定的工作表名稱和excel行號設置單行的可見。
func checkRow(xlsx *xlsxWorksheet) error
checkRow provides a function to check and fill each column element for all rows and make that is continuous in a worksheet of XML.
checkRow提供了一個函數,用于檢查和填充所有行的每個列元素,并使其在XML工作表中連續。
Noteice: this method could be very slow for large spreadsheets (more than 3000 rows one sheet).
注:對于大型電子表格(一張超過3000行),這種方法可能非常慢。
func (f *File) GetRowOutlineLevel(sheet string, row int) (uint8, error)
GetRowOutlineLevel provides a function to get outline level number of a single row by given worksheet name and Excel row number.
getRowOutlineLevel提供了一個函數,用于根據給定的工作表名稱和Excel行號獲取單行的大綱級別編號。
func (f *File) SetRowOutlineLevel(sheet string, row int, level uint8) error
SetRowOutlineLevel provides a function to set outline level number of a single row by given worksheet name and Excel row number.
SetRowOutlineLevel 提供了一個函數,用于根據給定的工作表名稱和Excel行號設置單行的大綱級別號。
func (f *File) GetRowVisible(sheet string, row int) (bool, error)
GetRowVisible provides a function to get visible of a single row by given worksheet name and Excel row number.
GetRowVisible 提供了一個函數,可以通過給定的工作表名稱和excel行號獲取是否該行顯示。
func (f *File) sharedStringsReader() *xlsxSST
sharedStringsReader provides a function to get the pointer to the structure after deserialization of xl/sharedStrings.xml.
sharedStringsReader提供了一個函數,用于在對xl/sharedStrings.xml進行反序列化之后獲取指向結構的指針。
func (f *File) DuplicateRowTo(sheet string, row, row2 int) error
DuplicateRowTo inserts a copy of specified row by it Excel number to specified row position moving down exists rows after target position.
DuplicateRowTo 按excel數字將指定行的副本插入到指定行位置在目標位置后下移已存在的行。
Use this method with caution, which will affect changes in references such as formulas, charts, and so on.
請謹慎使用此方法,這將影響公式、圖表等引用中的更改。
If there is any referenced value of the worksheet, it will cause a file error when you open it.
如果工作表中有任何引用值,則打開它時將導致文件錯誤。
The excelize only partially updates these references currently.
excelize當前僅部分更新這些引用。
總結
以上是生活随笔為你收集整理的Go + Excel 学习 Excelize rows.go的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Go + Excel 学习 Exceli
- 下一篇: AI Studio 学习 Go 豆瓣电影