- Fixed coordinate parse error in function `SetCellStyle()`, relate issue #60;

- Simplified code
This commit is contained in:
Ri Xu 2017-06-12 18:05:09 +08:00
parent c89d842352
commit efff54ccde
4 changed files with 6 additions and 8 deletions

View File

@ -210,7 +210,7 @@ func (f *File) SetCellDefault(sheet, axis, value string) {
}
// Completion column element tags of XML in a sheet.
func completeCol(xlsx *xlsxWorksheet, row int, cell int) {
func completeCol(xlsx *xlsxWorksheet, row, cell int) {
if len(xlsx.SheetData.Row) < cell {
for i := len(xlsx.SheetData.Row); i < cell; i++ {
xlsx.SheetData.Row = append(xlsx.SheetData.Row, xlsxRow{

View File

@ -218,7 +218,7 @@ func (f *File) addDrawingPicture(sheet, drawingXML, cell, file string, width, he
// addDrawingRelationships provides function to add image part relationships in
// the file xl/drawings/_rels/drawing%d.xml.rels by given drawing index,
// relationship type and target.
func (f *File) addDrawingRelationships(index int, relType string, target string) int {
func (f *File) addDrawingRelationships(index int, relType, target string) int {
var rels = "xl/drawings/_rels/drawing" + strconv.Itoa(index) + ".xml.rels"
var drawingRels xlsxWorkbookRels
var rID = 1
@ -257,7 +257,7 @@ func (f *File) countMedia() int {
// addMedia provides function to add picture into folder xl/media/image by given
// file name and extension name.
func (f *File) addMedia(file string, ext string) {
func (f *File) addMedia(file, ext string) {
count := f.countMedia()
dat, _ := ioutil.ReadFile(file)
media := "xl/media/image" + strconv.Itoa(count+1) + ext
@ -341,7 +341,7 @@ func (f *File) addContentTypePart(index int, contentType string) {
// getSheetRelationshipsTargetByID provides function to get Target attribute
// value in xl/worksheets/_rels/sheet%d.xml.rels by given sheet name and
// relationship index.
func (f *File) getSheetRelationshipsTargetByID(sheet string, rID string) string {
func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
var rels = "xl/worksheets/_rels/" + strings.ToLower(sheet) + ".xml.rels"
var sheetRels xlsxWorkbookRels
xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)

View File

@ -776,8 +776,8 @@ func (f *File) setCellStyle(sheet, hcell, vcell string, styleID int) {
xlsx := f.workSheetReader(sheet)
completeRow(xlsx, vxAxis+1, vyAxis+1)
completeCol(xlsx, vxAxis+1, vyAxis+1)
completeRow(xlsx, vyAxis+1, vxAxis+1)
completeCol(xlsx, vyAxis+1, vxAxis+1)
for r, row := range xlsx.SheetData.Row {
for k, c := range row.C {

View File

@ -236,12 +236,10 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
vxAxis := titleToNumber(vcol)
if vxAxis < hxAxis {
hcell, vcell = vcell, hcell
vxAxis, hxAxis = hxAxis, vxAxis
}
if vyAxis < hyAxis {
hcell, vcell = vcell, hcell
vyAxis, hyAxis = hyAxis, vyAxis
}
ref := toAlphaString(hxAxis+1) + strconv.Itoa(hyAxis+1) + ":" + toAlphaString(vxAxis+1) + strconv.Itoa(vyAxis+1)