Git Product home page Git Product logo

Comments (4)

wojciechczerniak avatar wojciechczerniak commented on May 12, 2024

Ok, I think I get it now.

if (sheetIndex !== address.sheet) {
return `\$${sheetName}.${column}${address.row + 1}`
} else {
return `${column}${address.row + 1}`
}

Basically sheet param is necessary to indicate where is the cell/sheet that requests the address so the returned address is either absolute or relative to that sheet. IMO this would be clearer with includeSheetName: boolean = false or absoluteSheetName: boolean = false.

Another question is how do we indicate that row or column should be absolute or relative?

from hyperformula.

swistak35 avatar swistak35 commented on May 12, 2024

Close, but not exactly. If we give engine to interpret C64, we don't know, whether this is in context of Sheet1 (the result would be: {sheet: 0, col: 2, row: 63}), or Sheet2 (the result would be: {sheet: 1, col: 2, row: 63}). So we need context, in which sheet we ask for that address. Of course, sheet is sometimes obvious -- when someone give us sheet explicit, like Sheet42!A1, but it's not always the case.

We can think of many different "formats" for addresses. But when we've worked on the engine, only two were really needed:

  • totally absolute address (SimpleCellAddress type) -- this one has only numerical values, all always absolute.
  • R0C0 format (CellAddress class). This one come up always with additional information, whether column/row is relative/absolute. The sheet is always absolute, because we didn't consider 3D references.

My suggestion is to wait, until we will really need some other formats than these two, because we can discuss many formats fora a long time, but that probably won't be productive :)

from hyperformula.

bardek8 avatar bardek8 commented on May 12, 2024

@wojciechczerniak Is there anything crucial left in this issue to be done in Dec19?

from hyperformula.

wojciechczerniak avatar wojciechczerniak commented on May 12, 2024

@bardek8 No. I think I understood it now correctly.

It would be helpful to extend the JSDoc to explain it better and override might not be the best name. I will ask if @scarletfog could take a look, having the context from @swistak35 should be easy to fill the gap if any.

/**
* Computes simple (absolute) address of a cell address based on it's string representation.
* If sheet name is present in string representation but is not present in engine, returns undefined.
* If sheet name is not present in string representation, returns {@param sheet} as sheet number
*
* @param stringAddress - string representation of cell address, e.g. 'C64'
* @param sheet - override sheet index regardless of sheet mapping
* @returns absolute representation of address, e.g. { sheet: 0, col: 1, row: 1 }
*/
public simpleCellAddressFromString(stringAddress: string, sheet: number) {
return simpleCellAddressFromString(this.sheetMapping.get, stringAddress, sheet)
}
/**
* Returns string representation of absolute address
* If sheet index is not present in engine, returns undefined
*
* @param address - object representation of absolute address
* @param sheet - if is not equal with address sheet index, string representation will contain sheet name
* */
public simpleCellAddressToString(address: SimpleCellAddress, sheet: number): string | undefined {
return simpleCellAddressToString(this.sheetMapping.name, address, sheet)
}

from hyperformula.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.