Real shipped codeFinancial modeling · SaaSReusable architecture

Rethinking data entry across an entire app

Letting the app's operators copy a row from Excel, Google Sheets or a CSV, paste it, and get numbers normalised in every language and currency, with the feature rolled out across 31 tables.

ClientValueize · Financial modeling platform
RoleTeam
Duration9 weeks
StackReact 19 · TanStack Table · TanStack Query · Zod · Vitest
01 · Context

Tables keep a product tidy. Then someone has to fill them in.

Valueize is a financial modeling platform covering headcount, revenue, COGS, opex, working capital and cash flow. Each of these modules contains several grid tables that the user fills in to build the model. A model typically describes 3-4 fiscal years of a business at monthly granularity.

An import feature existed, but the most common scenario was users importing partial or wrong files and ending up typing hundreds of cells by hand.

02 · Problem

Manual input, cell by cell, with the data already sitting on the other side of the screen.

The flow was technically correct and practically painfully slow. Every cell was a validated input, but validation protected the single value, not the user's time or the variety of spreadsheets the data came from.

1

One grid = dozens of cells to retype. A table is usually filled 3-4 years at a time: in the yearly view that's about ten cells per row, in the monthly view it becomes 12 periods per year. Repeated across every line item, it adds up to hundreds of manual inputs and hours spent filling tables.

2

Every spreadsheet speaks a different language. An Italian Excel writes 1.234,56, an American one 1,234.56; one CSV export adds the currency symbol, another uses thousands separators, yet another puts negatives in parentheses. Even if you tried to paste, the input would have rejected almost everything: every format is a different case to handle.

3

Nothing in between 'by hand' and 'full re-import'. If after an import you noticed four wrong cells in the middle of a huge table, you had two options: retype them by hand, or re-import the whole table. Neither is a correction; both mean starting over.

03 · Results

Data entry stopped being the bottleneck.

~30s to fill a table, down from an average of ~15 minutes typed by hand (3-4 years of data at a time)
31 tables in the app served by the same paste engine, with no ad-hoc code
100% of pastes reversible with an undo that touches only the affected cells
Before / after the change
Time to fill a table · before
~15 min
Time to fill a table · after
~30s
Spreadsheet formats accepted · before
manual input only
Spreadsheet formats accepted · after
Excel · Sheets · CSV
Tables with copy-paste · before
0
Tables with copy-paste · after
31

The number that matters most is '31 tables'. The feature reached everywhere because the parser and the table know nothing about each other: two small, generic contracts, wired together with a few lines of configuration per table.

04 · Solution

Copy the row from Excel. Paste it. Done.

A file import already existed, but it assumed a clean, complete spreadsheet. The typical user arrives with a hand-made plan instead: partial, messy, unlike any other, so a perfect import often wasn't even possible. Excel, Google Sheets and CSVs all put the same format on the clipboard, though: rows separated by line breaks, cells separated by tabs. One parser for that shared format is enough, instead of one per tool, and the row pastes as it is, without tidying anything first. It becomes a gesture instead of a procedure.

→

One gesture: right click, Paste. The user copies a row from their spreadsheet, right-clicks a cell and picks Paste. Before writing anything, a preview says how many cells are about to be pasted and shows the raw clipboard content: no surprises, you see what's about to happen.

→

It normalises the numbers on its own. 1.234,56 € and €1,234.56 are the same value written in two languages: both become 1234.56. Currency symbols, thousands separators, parentheses for negatives, spaces: the parser interprets them and reduces them to a clean number, whichever spreadsheet produced them.

→

Explicit guardrails, no silent truncation. If you paste more cells than the row has, the app tells you and lets you choose instead of cutting silently. If the selection contains empty cells, it offers three clear behaviours: fill them with zero, keep the current value, or skip them.

→

Every paste is reversible. Right after pasting, the menu offers an Undo that restores only the cells it touched, leaving the rest of the row and the table alone. That ends the 'retype or re-import' dilemma: you fix four cells in the middle of a huge grid without starting over.

The monthly headcount grid: previously filled one cell at a timePaste preview: 'Paste 16 Cells' with the raw clipboard contentThree modes for empty cells: fill, keep the current value, skipLimit guardrail: you paste 16 cells but the row supports 12, the app asks for confirmationTargeted undo: 'Undo 12 Cells' restores only the cells just pasted
The new flow: from the grid to fill in to the paste preview, the guardrails on row limits and empty cells, through to the targeted undo.
05 · Under the hood

Abstraction over duplication: two generic contracts.

Underneath there are two things, deliberately kept apart. A pure parser that knows nothing about tables: it takes text from the clipboard and returns validated numbers. And a generic provider that knows nothing about numbers: it takes a list of data and a key, and knows how to paste, validate, mutate and undo. They fit together with minimal config, which is why the same feature ended up in 31 different tables without a single line of dedicated code.

{1}

One parser, any spreadsheet. An Excel/Sheets/CSV paste is tab-separated text: it's split on line breaks and tabs, and each cell goes through an interchangeable validator. The validators are Zod schemas (numeric, percentage, positive numeric) and the table picks one by passing a string. Adding a new one doesn't touch the parser.

DeepDive · the clipboard parser TS
Split rows and cells, validate one by one
export function parseExcelData(
  pastedData: string,
  options: ClipboardParseOptions
): ClipboardParseResult {
  const rows = pastedData.split(/\r\n|\r|\n/) // Windows, Mac, Unix
  if (rows.length > 0 && rows[rows.length - 1] === ``) rows.pop()

  const cells = (rows[0] ?? ``).split(`\t`) // Excel/Sheets/CSV → tab-separated
  const parsedData: ClipboardParsedItem[] = []

  cells.forEach((cell, index) => {
    const trimmed = cell.trim()
    const { success, value, error } =
      typeof options.validate === `function`
        ? options.validate(trimmed)
        : VALIDATE_FNS[options.validate](trimmed) // validator chosen by the table
    parsedData.push({ id: index, originalValue: trimmed, validatedValue: value, error })
  })

  return { clipboardContent: pastedData, data: parsedData, /* ...errors */ }
}
Interchangeable validators, as Zod schemas
const VALIDATE_FNS = {
  numeric: (input: string) => run(z.string().transform(parseInputValue)
    .refine((v) => !Number.isNaN(Number(v)), `invalid_numeric`), input),

  percentage: (input: string) => run(z.string().transform(parseInputValue)
    .refine((v) => !Number.isNaN(Number(v)), `invalid_numeric`)
    .refine((v) => Number(v) >= 0 && Number(v) <= 100, `invalid_percentage`), input),

  positiveNumeric: (input: string) => run(z.string().transform(parseInputValue)
    .refine((v) => !Number.isNaN(Number(v)), `invalid_numeric`)
    .refine((v) => Number(v) >= 0, `invalid_positive`), input),
}
// the table picks with a string: dataValidationType="percentage"
{2}

Numbers, in any language and currency. The core is parseInputValue. First it cleans up: currency symbols, letters, spaces and percentages go; parentheses become a minus sign. Then it disambiguates the trickiest part, thousands separator versus decimal separator, with a precise rule instead of a guess.

DeepDive · decimal parsing TS
Cleanup: currency, letters, spaces, parentheses = negative
const cleanInput = (value: string) => {
  const parsed = value
    .replace(currencySymbolsPattern, ``) // €, $, £, ...
    .replace(/[a-zA-Z]/g, ``)
    .replace(/[%]/, ``)
    .replace(/[" "]/g, ``)
    .trim()

  // accounting notation: (342) → -342
  const hasParentheses = parsed.startsWith(`(`) && parsed.endsWith(`)`)
  return hasParentheses ? `-${parsed.slice(1, -1)}` : parsed
}
Thousands or decimals? A rule instead of a guess
const processDecimalPart = (value: string) => {
  let processedValue = value
  if (value.includes(`,`)) {
    const parts = value.split(`,`)
    // 2 digits after the comma → it's a decimal (1234,56 → 1234.56)
    if (parts[1]?.length <= 2) processedValue = value.replace(`,`, `.`)
    // otherwise it's a thousands separator (1,234 → 1234)
    else processedValue = value.replace(/,/g, ``)
  }
  // several dots: the last one is the decimal, the others are thousands
  const split = processedValue.split(`.`)
  if (split.length > 1) {
    const decimalPart = split.pop()
    return `${split.join(``)}.${decimalPart}`
  }
  return processedValue
}
Mixed separators: both present
// "1.234,56" and "1,234.56" coexist: the last separator is the decimal
const handleMixedSeparators = (value: string) => {
  const parts = value.split(/[,.]/)
  if (parts.length >= 2) {
    const decimalPart = parts.pop()
    return `${parts.join(``)}.${decimalPart}`
  }
  return parts.join(``)
}

export const parseInputValue = (value: string) => {
  const parsed = cleanInput(value)
  if (INVALID_NUMERIC_INPUTS.includes(parsed)) return ``      // ".", ",", "..." → discarded
  if (parsed.includes(`,`) && parsed.includes(`.`)) return handleMixedSeparators(parsed)
  return processDecimalPart(parsed)
}
{3}

One function, dozens of tables. The provider is generic over the row type: TableActionableRowProvider<DataItem>. It doesn't know what a 'headcount' or 'revenue' cell is. It receives the current data, the table's mutation function and, the key piece, mutateDataKey: the path to the field to update, typed on the nested keys of DataItem. That's how the same provider serves completely different data structures.

DeepDive · the generic provider TS
The signature: generic over the data, with a typed key
export const TableActionableRowProvider = <DataItem extends object>({
  children,
  currentData,
  mutateDataKey,                       // path to the field, e.g. "value" or "config.rate"
  rowUpdateMutationArgs: { mutationItemFn },
  dataValidationType = `numeric`,      // which Zod validator the parser uses
}: {
  currentData: DataItem[]
  mutateDataKey: NestedKeyOf<DataItem>  // only valid paths for DataItem
  dataValidationType?: ClipboardParseValidationType
  rowUpdateMutationArgs: {
    mutationItemFn: (item: DataItem & { itemIndex: number }, extra: {
      rowType: StandardInputType
    }) => Promise<unknown>
  }
}) => { /* ... */ }
NestedKeyOf: the path is checked by the compiler
// "id" | "config" | "config.rate" | "config.view" ... — no random strings
type NestedKeyOf<T> = {
  [K in keyof T & (string | number)]: T[K] extends object
    ? `${K}` | `${K}.${NestedKeyOf<T[K]>}`
    : `${K}`
}[keyof T & (string | number)]
The patch follows the path without mutating the original
function getPatchedObjectByNestedProps<T extends object, V>(obj: T, path: string, value: V): T {
  const result = { ...obj }
  const keys = path.split(`.`)
  let current = result as Record<string, any>
  for (let i = 0; i < keys.length - 1; i++) {
    current[keys[i]] = { ...current[keys[i]] } // copy the nested level
    current = current[keys[i]]
  }
  current[keys[keys.length - 1]] = value
  return result
}
{4}

Surgical edits instead of re-imports. The three paste modes, the row-limit guardrail, and an undo that restores only the affected cells. Mutations run in parallel but in groups of ten, with per-cell feedback: a large grid doesn't freeze the interface and an error on one cell doesn't fail the others.

DeepDive · paste, limits, batches, undo TS
Three explicit modes for empty cells
const PASTE_ACTION_TYPES = {
  PASTE_ALL: `PASTE_ALL`,                     // paste everything
  PASTE_PRESERVE_EMPTY: `PASTE_PRESERVE_EMPTY`, // empty → keep the current value
  PASTE_SKIP_EMPTY: `PASTE_SKIP_EMPTY`,        // empty → skip the cell
} as const

const typePrepareFn = {
  [PASTE_ACTION_TYPES.PASTE_ALL]: (cps) => cps.data,
  [PASTE_ACTION_TYPES.PASTE_PRESERVE_EMPTY]: (cps) => cps.data,
  [PASTE_ACTION_TYPES.PASTE_SKIP_EMPTY]: (cps) =>
    cps.data.filter((item) => item.validatedValue !== ``),
}
The limit guardrail: ask, don't truncate
// pasting more cells than remain in the row from the starting point?
if (clipboardParseResult.data.length > currentData.length - triggerCellIndex) {
  errorCode = PENDING_PASTE_ERROR.LIMIT_OVERFLOW // → dialog "Paste within limit?"
}
Mutations in batches of 10, per-cell feedback
// allSettled instead of Promise.all: one failing cell doesn't take down the others
const promises = args.upsertData.map((item, index) =>
  mutationItemFn(item, { rowType })
    .then(() => ({ item, index, success: true }))
    .catch(() => ({ item, index, success: false }))
)

const batchSize = 10
const batched = []
for (let i = 0; i < promises.length; i += batchSize) {
  batched.push(Promise.all(promises.slice(i, i + batchSize)))
}
const results = (await Promise.all(batched)).flat()
// each result updates its own cell's feedback (green/red)
Targeted undo: only the cells touched
const restoreDataCells = fullRowDataBeforePaste.filter(
  (_, i) =>
    i >= contextMenuTriggerCellIndex &&
    i < contextMenuTriggerCellIndex + pastedData.length
)
// restores the previous state only on those cells: no calls
// for the rest of the row, which was never touched
06 · The extra mile

Multi-language and multi-currency, tested on every combination.

A financial number parser fails silently: 1,234 is one thousand two hundred thirty-four to an American and one-point-two-three-four to an Italian, and misreading a figure means corrupting a balance sheet without anyone noticing. That's why the parser is covered by more than a few hand-picked tests: a suite runs it on every supported language crossed with every allowed currency, plus the edge cases that break naive parsers: mixed separators, accounting parentheses, symbols stuck to the number, garbage input.

DeepDive · the parsing suite TS
Every language × every currency: format and re-parse
it(`Should return number without currency`, () => {
  ALLOWED_CURRENCIES.forEach((currency) => {
    numbers.forEach((number) => {
      const formatted = formatNumber(number.input, { currency, style: `currency` })
      // whatever currency writes it, the parser must get the clean number back
      expect(parseInputValue(formatted)).toBe(Number(number.expected).toFixed(number.precision))
    })
  })
})

it(`Should return formatted number for all supported locales`, () => {
  SUPPORTED_LOCALES.forEach((locale) => {
    numbers.forEach((number) => {
      const formatted = formatNumber(number.input, { language: locale })
      expect(parseInputValue(formatted)).toBe(Number(number.expected).toFixed(number.precision))
    })
  })
})
The edge cases that break naive parsers
expect(parseInputValue(`1,234.56`)).toBe(`1234.56`)   // US thousands + decimal
expect(parseInputValue(`1234,56`)).toBe(`1234.56`)    // IT decimal
expect(parseInputValue(`1.234,567.89`)).toBe(`1234567.89`) // mixed separators
expect(parseInputValue(`(342,56)`)).toBe(`-342.56`)   // parentheses = negative
expect(parseInputValue(`$1234.56`)).toBe(`1234.56`)   // attached symbol
expect(parseInputValue(`1 234.56`)).toBe(`1234.56`)   // space as separator

// input that is NOT a number must not silently become 0
INVALID_NUMERIC_INPUTS.forEach((input) => expect(parseInputValue(input)).toBe(``))
07 · Challenges

What could have gone wrong (and how we avoided it).

The comma that corrupts a balance sheet. The ambiguity between thousands and decimal separators is far more than cosmetic: reading 1,234 as 1234 instead of 1.234 inflates a number a thousandfold, silently, inside a financial model. The defence is a deterministic rule (two digits after the separator are decimals, three or more are thousands) instead of guessing the user's language, plus a test suite that checks it on every language and currency before any parser change reaches production.

The parallel paste that returned the wrong cell. The first version sent every mutation in a single Promise.all. On refetch, with large selections, the first cell often didn't show the pasted value, even though the POST request was correct. A comment in the code still documents it. The fix was moving to allSettled in groups of ten: errors stay isolated to their cell and no updates are lost, keeping even a large grid responsive.

08 · Before / After

What actually changed.

Before
Time to fill a table ~15 min
  • Manual input cell by cell: ~15 min per table on average, often 3-4 years of data at once
  • Every spreadsheet format (currency, separators, language) adapted by hand
  • Four wrong cells = retype or re-import the whole table
  • Zero tables with copy-paste
After
Time to fill a table ~30s
  • Direct copy-paste from Excel, Google Sheets or CSV
  • Numbers normalised in every language and currency by a single parser
  • Targeted undo on the touched cells only, no re-import
  • The same engine reused in 31 tables, with no dedicated code

Got a complicated flow slowing your users down?

Let's talk: 30 minutes to look at it together, see whether it can be reduced to a few gestures, and tell you honestly whether it's worth it.

Book a 30-minute call   More case studies
Free review of your product.  Book 30 minutes →