Cell format Registry

Spreadsheet lets you store and compress duplicate format data using cellxfs registries

Cell format registry lets you store formats in a central place.. And reference the format using an ID in userEnteredFormat and effectiveFormat. This will give an 70% compression on cell data

// Before cellXfs registry
// Cell data A1:

{
  userEnteredFormat: {
    backgroundColor: "green",
    horizontalAlignment: "left"
  },
  effectiveFormat: {
    backgroundColor: "green",
    horizontalAlignment: "left"
  },
  userEnteredValue: {
    stringValue: "Cell with styleId",
  },
  formattedValue: "Cell with styleId",
  note: "Hello world, this is notes.",
},

// After cellXfs registry
{
  userEnteredFormat: {
    styleId: 123,
  },
  effectiveFormat: {
    styleId: 123,
  },
  userEnteredValue: {
    stringValue: "Cell with styleId",
  },
  formattedValue: "Cell with styleId",
  note: "Hello world, this is notes.",
},

Usage

const App = () => {
  const [cellXfs, onChangeCellXfs] = useState<CellXfs | null | undefined>(
    new Map()
  );
  
  // With useSpreadsheetstate
  const { getEffectiveFormat } = useSpreadsheetState({
     cellXfs,
     onChangeCellXfs
  })
  
  // With yjs
  const { } = useYSpreadsheetV2({
     onChangeCellXfs
  })
  
  return (
      <CanvasGrid getEffectiveFormat={getEffectiveFormat} />
  )
  
}

Last updated

Was this helpful?