forked from p30928647/excelize
- Bugfix: use sheet name in func `AddPicture`, relate issue #142;
- godoc updated
This commit is contained in:
parent
ebafbdde73
commit
f10ee929d0
8
cell.go
8
cell.go
|
@ -85,9 +85,9 @@ func (f *File) SetCellValue(sheet, axis string, value interface{}) {
|
|||
}
|
||||
|
||||
// GetCellValue provides function to get formatted value from cell by given
|
||||
// sheet index and axis in XLSX file. If it is possible to apply a format to the
|
||||
// cell value, it will do so, if not then an error will be returned, along with
|
||||
// the raw value of the cell.
|
||||
// worksheet name and axis in XLSX file. If it is possible to apply a format to
|
||||
// the cell value, it will do so, if not then an error will be returned, along
|
||||
// with the raw value of the cell.
|
||||
func (f *File) GetCellValue(sheet, axis string) string {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
axis = f.mergeCellsParser(xlsx, axis)
|
||||
|
@ -191,7 +191,7 @@ func (f *File) GetCellFormula(sheet, axis string) string {
|
|||
}
|
||||
|
||||
// SetCellFormula provides function to set cell formula by given string and
|
||||
// sheet index.
|
||||
// worksheet name.
|
||||
func (f *File) SetCellFormula(sheet, axis, formula string) {
|
||||
xlsx := f.workSheetReader(sheet)
|
||||
axis = f.mergeCellsParser(xlsx, axis)
|
||||
|
|
2
chart.go
2
chart.go
|
@ -238,7 +238,7 @@ func (f *File) countCharts() int {
|
|||
}
|
||||
|
||||
// prepareDrawing provides function to prepare drawing ID and XML by given
|
||||
// drawingID, worksheet index and default drawingXML.
|
||||
// drawingID, worksheet name and default drawingXML.
|
||||
func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawingXML string) (int, string) {
|
||||
sheetRelationshipsDrawingXML := "../drawings/drawing" + strconv.Itoa(drawingID) + ".xml"
|
||||
if xlsx.Drawing != nil {
|
||||
|
|
4
col.go
4
col.go
|
@ -15,7 +15,7 @@ const (
|
|||
)
|
||||
|
||||
// GetColVisible provides a function to get visible of a single column by given
|
||||
// worksheet index and column name. For example, get visible state of column D
|
||||
// worksheet name and column name. For example, get visible state of column D
|
||||
// in Sheet1:
|
||||
//
|
||||
// xlsx.GetColVisible("Sheet1", "D")
|
||||
|
@ -36,7 +36,7 @@ func (f *File) GetColVisible(sheet, column string) bool {
|
|||
}
|
||||
|
||||
// SetColVisible provides a function to set visible of a single column by given
|
||||
// worksheet index and column name. For example, hide column D in Sheet1:
|
||||
// worksheet name and column name. For example, hide column D in Sheet1:
|
||||
//
|
||||
// xlsx.SetColVisible("Sheet1", "D", false)
|
||||
//
|
||||
|
|
|
@ -78,7 +78,7 @@ func (f *File) setDefaultTimeStyle(sheet, axis string) {
|
|||
}
|
||||
|
||||
// workSheetReader provides function to get the pointer to the structure after
|
||||
// deserialization by given worksheet index.
|
||||
// deserialization by given worksheet name.
|
||||
func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
|
||||
name, ok := f.sheetMap[trimSheetName(sheet)]
|
||||
if !ok {
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestOpenFile(t *testing.T) {
|
|||
xlsx.SetActiveSheet(2)
|
||||
// Test get cell formula with given rows number.
|
||||
xlsx.GetCellFormula("Sheet1", "B19")
|
||||
// Test get cell formula with illegal worksheet index.
|
||||
// Test get cell formula with illegal worksheet name.
|
||||
xlsx.GetCellFormula("Sheet2", "B20")
|
||||
// Test get cell formula with illegal rows number.
|
||||
xlsx.GetCellFormula("Sheet1", "B20")
|
||||
|
@ -638,6 +638,7 @@ func TestGetPicture(t *testing.T) {
|
|||
xlsx.getDrawingRelationships("xl/worksheets/_rels/sheet1.xml.rels", "rId8")
|
||||
xlsx.getDrawingRelationships("", "")
|
||||
xlsx.getSheetRelationshipsTargetByID("", "")
|
||||
xlsx.deleteSheetRelationships("", "")
|
||||
}
|
||||
|
||||
func TestSheetVisibility(t *testing.T) {
|
||||
|
|
|
@ -364,7 +364,11 @@ func (f *File) addContentTypePart(index int, contentType string) {
|
|||
// value in xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name and
|
||||
// relationship index.
|
||||
func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
|
||||
var rels = "xl/worksheets/_rels/" + strings.ToLower(sheet) + ".xml.rels"
|
||||
name, ok := f.sheetMap[trimSheetName(sheet)]
|
||||
if !ok {
|
||||
name = strings.ToLower(sheet) + ".xml"
|
||||
}
|
||||
var rels = "xl/worksheets/_rels/" + strings.TrimPrefix(name, "xl/worksheets/") + ".rels"
|
||||
var sheetRels xlsxWorkbookRels
|
||||
xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
|
||||
for _, v := range sheetRels.Relationships {
|
||||
|
|
Loading…
Reference in New Issue