-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pu/issue617 #619
Pu/issue617 #619
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #619 +/- ##
========================================
Coverage 92.45% 92.45%
========================================
Files 164 164
Lines 38428 38460 +32
Branches 5330 5337 +7
========================================
+ Hits 35527 35559 +32
Misses 2864 2864
Partials 37 37
|
as per the `.tgz` filename change, updates hyperformula to the version from this PR: handsontable/hyperformula#619
When you type into cell |
@izulin Same with date format, currency or percent sign, yet, we keep them. HyperFormula does not have UI, exported content from the Excel should be correctly calculated without altering the data and serialized without loosing any parts of it. And it's not stripped, Excel keeps the info and it will be shown in the formula bar as the cell content: |
Try accessing the cell value, e.g. type |
leading '
should probably also get omitted when referencing the cell in a formula
@wojciechczerniak Ok, lets see how you like this approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outcome is what we're looking for. But maybe it would be more useful to have internal getSerializedValue
or getRawValue
method instead literal
arg?
I think we should look at serialization again. It does not work as intended. With getSheetSerialized
I should be able to store and recreate the engine.
Consider an example:
- User loads the app: initialize engine with data from server
- User logs out / saves data: send
getAllSheetsSerialized
to server and store in databse / file - User logs in again, reinitialize the engine with data from server
- Data was lost in the process 💣 💥
it('should not loose sheet information on serialziation', () => {
const engine1 = HyperFormula.buildFromArray([
[1, '2', 'foo', true, '\'1', '33$', '12/01/15']
])
expect(engine1.getCellSerialized(adr('A1'))).toEqual(1)
expect(engine1.getCellValueFormat(adr('A1'))).toEqual(undefined)
expect(engine1.getCellValueDetailedType(adr('A1'))).toEqual(CellValueDetailedType.NUMBER_RAW)
expect(engine1.getCellSerialized(adr('B1'))).toEqual(2)
expect(engine1.getCellValueFormat(adr('B1'))).toEqual(undefined)
expect(engine1.getCellValueDetailedType(adr('B1'))).toEqual(CellValueDetailedType.NUMBER_RAW)
expect(engine1.getCellSerialized(adr('C1'))).toEqual('foo')
expect(engine1.getCellValueFormat(adr('C1'))).toEqual(undefined)
expect(engine1.getCellValueDetailedType(adr('C1'))).toEqual(CellValueDetailedType.STRING)
expect(engine1.getCellSerialized(adr('D1'))).toEqual(true)
expect(engine1.getCellValueFormat(adr('D1'))).toEqual(undefined)
expect(engine1.getCellValueDetailedType(adr('D1'))).toEqual(CellValueDetailedType.BOOLEAN)
expect(engine1.getCellSerialized(adr('E1'))).toEqual('\'1')
expect(engine1.getCellValueFormat(adr('E1'))).toEqual(undefined)
expect(engine1.getCellValueDetailedType(adr('E1'))).toEqual(CellValueDetailedType.STRING)
expect(engine1.getCellSerialized(adr('F1'))).toEqual(33)
expect(engine1.getCellValueFormat(adr('F1'))).toEqual('$')
expect(engine1.getCellValueDetailedType(adr('F1'))).toEqual(CellValueDetailedType.NUMBER_CURRENCY)
expect(engine1.getCellSerialized(adr('G1'))).toEqual(42016)
expect(engine1.getCellValueFormat(adr('G1'))).toEqual(undefined)
expect(engine1.getCellValueDetailedType(adr('G1'))).toEqual(CellValueDetailedType.NUMBER_DATE)
// serialize and "send" data to server
const serialized = engine1.getAllSheetsSerialized();
// reload data and "restore" the previous state
const engine2 = HyperFormula.buildFromSheets(serialized)
expect(engine2.getCellSerialized(adr('A1'))).toEqual(1)
expect(engine2.getCellValueFormat(adr('A1'))).toEqual(undefined)
expect(engine2.getCellValueDetailedType(adr('A1'))).toEqual(CellValueDetailedType.NUMBER_RAW)
expect(engine2.getCellSerialized(adr('B1'))).toEqual(2)
expect(engine2.getCellValueFormat(adr('B1'))).toEqual(undefined)
expect(engine2.getCellValueDetailedType(adr('B1'))).toEqual(CellValueDetailedType.NUMBER_RAW)
expect(engine2.getCellSerialized(adr('C1'))).toEqual('foo')
expect(engine2.getCellValueFormat(adr('C1'))).toEqual(undefined)
expect(engine2.getCellValueDetailedType(adr('C1'))).toEqual(CellValueDetailedType.STRING)
expect(engine2.getCellSerialized(adr('D1'))).toEqual(true)
expect(engine2.getCellValueFormat(adr('D1'))).toEqual(undefined)
expect(engine2.getCellValueDetailedType(adr('D1'))).toEqual(CellValueDetailedType.BOOLEAN)
expect(engine2.getCellSerialized(adr('E1'))).toEqual('\'1')
expect(engine2.getCellValueFormat(adr('E1'))).toEqual(undefined)
expect(engine2.getCellValueDetailedType(adr('E1'))).toEqual(CellValueDetailedType.STRING)
expect(engine2.getCellSerialized(adr('F1'))).toEqual(33)
expect(engine2.getCellValueFormat(adr('F1'))).toEqual('$')
expect(engine2.getCellValueDetailedType(adr('F1'))).toEqual(CellValueDetailedType.NUMBER_CURRENCY)
expect(engine2.getCellSerialized(adr('G1'))).toEqual(42016)
expect(engine2.getCellValueFormat(adr('G1'))).toEqual(undefined)
expect(engine2.getCellValueDetailedType(adr('G1'))).toEqual(CellValueDetailedType.NUMBER_DATE)
})
BTW. does the getCellValueFormat
work for NUMBER_DATE?
I think that we should a better serialization approach for all the value types, not only the escaped string
Don't get me wrong! This is a good solution for the issue at hand. But I think we're going in the wrong direction overall and we will create a technical debt while we can introduce |
Good catch. I agree this should be handled in a more integrated form. |
@wojciechczerniak This actually induced a larger refactor (yay CRUDS, yay Matrices!) |
This pull request introduces 6 alerts when merging 706ae9c into e6cf049 - view on LGTM.com new alerts:
|
This pull request introduces 6 alerts when merging 45635e0 into e6cf049 - view on LGTM.com new alerts:
|
This pull request introduces 6 alerts when merging a57488b into 82c0053 - view on LGTM.com new alerts:
|
Known issue: raw value is lost if the numeric input becomes part of a matrix. |
This pull request introduces 8 alerts when merging ab20ae8 into 82c0053 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 🍻
Just few cosmetic questions if you don't mind
test/serialization.spec.ts
Outdated
expect(engine1.getCellValueDetailedType(adr('F1'))).toEqual(CellValueDetailedType.NUMBER_CURRENCY) | ||
|
||
expect(engine1.getCellSerialized(adr('G1'))).toEqual('12/01/15') | ||
expect(engine1.getCellValueFormat(adr('G1'))).toEqual(undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a note that this is wrong? With link to #626
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
riiiight
test/serialization.spec.ts
Outdated
describe('serialization', () => { | ||
it('should not loose sheet information on serialization', () => { | ||
const engine1 = HyperFormula.buildFromArray([ | ||
[1, '2', 'foo', true, '\'1', '33$', '12/01/15'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add %
and a literal error #DIV/0
, =#CUSTOM!
so we have the whole picture here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -643,7 +643,7 @@ export class HyperFormula implements TypedEmitter { | |||
* | |||
* @category Cells | |||
*/ | |||
public getCellSerialized(cellAddress: SimpleCellAddress): NoErrorCellValue { | |||
public getCellSerialized(cellAddress: SimpleCellAddress): RawCellContent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider this as a breaking change to the public API? IMO yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
This pull request introduces 8 alerts when merging cebeeca into 82c0053 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Context
Makes it so raw value used for initialization is stored together with parsed value in the graph.
Raw value is produced when engine is asked for serialization.
Fixes issue #617 by making it so
'
is not dropped when provided as an input to the engine.How has this been tested?
Types of changes
Related issue(s):
'
#617Checklist: