qax-os / excelize

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
17.99k stars 1.71k forks source link

Handle and updates worksheet dimensions automatically #1200

Open Strangeralonel opened 2 years ago

Strangeralonel commented 2 years ago

I used "excel" to add a line at the end of the workbook and save it. It's work, and both office and WPS can preview it.

But when I use Node to read this file, I can't read the newly added content. The NODE found an attribute "! Ref". This area is still the old attribute

It is worth mentioning that when I found that the NODE could not read the information normally, I saved it again with "office / WPS". It is found that the node can be read normally.

So I guess "! Ref" represents the content range of EXECL. Whether to update the relevant content when it is not saved. Unfortunately, my ability is not enough to read the source code and modify it.

My Go Code:

        file, err := excelize.OpenFile("./1.xlsx")
    if err != nil {
        log.Println("open err: ", err)
    }
    file.SetCellInt("Sheet1", "A2", 22)
    file.SetCellInt("Sheet1", "B2", 22)

    if err := file.Save(); err != nil {
        log.Println("save err :", err)
    }

My Node Code:

let xlsx = require('xlsx');

let workbook = xlsx.readFile('1.xlsx');

let sheetNames = workbook.SheetNames;

console.log(workbook.Sheets["Sheet1"])

Describe the results you received: image

Describe the results you expected: '!ref': 'A2:B2',

Go Environment: go version go1.15.6 darwin/amd64 github.com/xuri/excelize/v2 v2.5.0

Node Environment: v16.14.2 xlsx: "^0.18.5"

Thanks

xuri commented 2 years ago

Thanks for your feedback. Please provide your input file attachment without confidential info if you can.

Strangeralonel commented 2 years ago

okay ~ @xuri

this just a test file

1.xlsx

xuri commented 2 years ago

This library doesn't handle and updates worksheet dimensions automatically when saving the spreadsheet currently. I'll consider adding this feature support later. You can calculate it by the total columns and rows of the worksheet.

Strangeralonel commented 2 years ago

Thanks, can i see this feature in the next version? Sorry, I didn't mean to urge you。because it too important to me ~~

xuri commented 2 years ago

Sorry, this feature won't be released in the next version. You can calculate it by the total columns and rows of the worksheet.