# Shared strings

Shared strings let you store repeated text in a central Map and reference it by key from each cell. This reduces duplicated text in `sheetData` and keeps imports/exports consistent with Excel-style shared strings.

When shared strings are enabled, a cell can store an `ss` key and the actual text lives in `sharedStrings`. If `ss` is present, it takes precedence over any string or formatted value on the cell.

```tsx
// Before shared strings
{
  ue: { sv: "Hello" },
  fv: "Hello",
}

// With shared strings (Map-based)
{
  ss: "0"
}
// sharedStrings.get("0") === "Hello"
```

### Usage

```tsx
const App = () => {
  const [sharedStrings, onChangeSharedStrings] = useState<Map<string, string>>(
    new Map(),
  );

  const {
    getFormattedValue,
    getEffectiveExtendedValue,
    getUserEnteredExtendedValue,
  } = useSpreadsheetState({
    sharedStrings,
    onChangeSharedStrings,
  });

  // YJS automatically uses Map-based shared strings
  useYSpreadsheetV2({
    onChangeSharedStrings,
  });

  // For search, so it looks for shared strings index
  useSearch({
    getFormattedValue,
  });

  return (
    <CanvasGrid
      getFormattedValue={getFormattedValue}
      getUserEnteredExtendedValue={getUserEnteredExtendedValue}
      getEffectiveExtendedValue={getEffectiveExtendedValue}
    />
  );
};
```

### Import and export

* Excel/ODS/CSV imports honor `enabledSharedStrings`.
* Exports use `sharedStrings` when `ss` is present (shared strings take precedence over cell-level string/format values).

### Notes

* Shared string entries are not garbage-collected on delete, similar to Excel. Cells simply stop referencing their keys.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rowsncolumns.app/configuration/features/shared-strings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
