Back to all posts
Backend8 min read·November 22, 2026

Bulk Import From Excel: Designing an Import That Protects Data

TB
ThynkBlox Team
Engineering

To bulk import Excel data into a web app safely, give users a template, let them map their columns, validate every row, and show a preview with errors before anything is saved. Then detect duplicates, let users download an error report to fix and re-upload, and keep an undo for each import. This article covers a recurring import feature that staff use again and again, not a one-time migration.

What makes a recurring import different from a one-time migration?

A one-time migration is run by a project team, checked by specialists and then retired. A recurring import is run by ordinary staff, often in a hurry, with files that vary from week to week. Nobody is standing by to clean up afterwards.

That changes the design. The feature must explain its own mistakes in plain words, stop bad data from entering, and let the person fix the file without calling support. If you are replacing a whole system, plan that separately in a data migration plan for replacing business software.

How should the template and column mapping work?

Offer a template download with the expected column headings, a short note on each field and a sample row. A template prevents many avoidable errors before the file is even uploaded.

Users will still upload files with their own headings, so add a mapping step. Show each column found in the file next to the field it appears to match, and let the user correct the match. Mark required fields clearly, and let users skip columns they do not need.

Save the mapping for next time when the file layout is the same, so a weekly import does not repeat the same setup.

What should row-level validation check?

Validate each row on its own and report every problem, not just the first one. Users who see one error per upload will give up after the third attempt.

CheckExample errorWhat the user sees
Required fieldCustomer name is emptyRow 14, Name: this field is required
FormatEmail has no @ signRow 27, Email: enter a valid email address
Allowed valuesStatus is "Actve"Row 31, Status: choose Active or Inactive
Range or typeQuantity is text, not a numberRow 45, Quantity: enter a whole number
Cross-field ruleEnd date is before start dateRow 52, End date: must be after the start date
Duplicate in fileSame email appears twiceRows 60 and 88: this email appears more than once
Duplicate in systemCustomer already existsRow 71: matches an existing customer

Write messages that name the row, the column and the fix. Keep the original row number from the spreadsheet so users can find it.

Why show a preview before anything is saved?

The preview is the point where users can still change their mind. Nothing is written to the main data until they confirm.

Show a summary first: rows read, rows ready, rows with errors and rows that look like duplicates. Below it, show a sample of the clean rows as they will appear, and a list of the problem rows with their messages. Let users filter the list to errors only.

Validation and saving are separate steps. The preview is built from a staging area, so closing the browser leaves your data untouched.

Should an import be all-or-nothing or partial?

Both are valid. The right choice depends on what the data means.

  • All-or-nothing: if any row fails, nothing is saved. Choose this when rows depend on each other, such as an order with its lines, or when a half-loaded file would be hard to reason about.
  • Partial: valid rows are saved and invalid rows are returned for correction. Choose this when rows are independent, such as a customer list, and when the file is large enough that rejecting everything over one typo would frustrate people.

Whichever you pick, say so on the preview screen before the user confirms. A surprise is the worst outcome: users who expected everything to load and find only part of it will lose trust in the feature.

How do you detect duplicates?

Decide what makes two rows the same record. For customers it might be an email address or a phone number; for products, a code. Check for matches within the file and against existing records.

Then decide what happens on a match:

  1. Skip the row and report it.
  2. Update the existing record with the new values.
  3. Import it anyway, only if the user explicitly chooses to.

Show the matched record in the preview so the user can judge. Matching on names alone is fragile because spellings differ, so prefer a stable identifier and normalise it first, for example by trimming spaces and ignoring letter case.

Duplicates also arise when a user uploads the same file twice after a slow screen. The same thinking applies as in API idempotency to prevent duplicate transactions: make repeating an action safe.

What does the error report look like?

Give users a downloadable file containing only the rows that failed, in the same layout as the template, with an extra column explaining each problem. They fix the rows and upload that file again.

This loop matters more than any other part of the feature. Without it, users must hunt through the original spreadsheet, and corrections get mixed with rows that were already saved. With partial imports, the re-upload contains only the failed rows, so nothing is loaded twice.

What should undo and rollback do?

Record each import as a batch, with who ran it, when, and which records it created or changed. An undo then removes or restores exactly those records.

Decide the limits in advance. If someone has edited an imported record since, should undo skip it, warn the user or overwrite their work? Ask users to confirm, and explain what will happen. Keep a history of imports so support staff can see what changed. For wider guidance on recording changes, see data security in modern applications.

What does a worked example look like?

These numbers are illustrative. A sales team uploads a file of 200 customer rows using the template.

  1. Mapping: the file's "Mobile" heading is matched to the Phone field. The user confirms.
  2. Validation: the system reads all 200 rows and finds three problems.
  3. Preview: the summary shows 197 rows ready and 3 with errors.
RowProblemMessage shown
38Email missing the @ signEmail: enter a valid email address
112Name emptyName: this field is required
163Email matches an existing customerMatches an existing customer: skip or update
  1. Choice: the import is set to partial. The user confirms and 197 customers are saved.
  2. Fix: the user downloads an error report with three rows, corrects the first two, decides to skip the third, and uploads the file again. Two more customers are saved.
  3. Undo: if the user later realises the wrong file was used, the import history lets them undo that batch and remove the 199 customers it created.

At no point did the user need to edit a database or ask a developer for help.

What common mistakes should you avoid?

Saving rows while validating. A failed import then leaves half-loaded data behind. Validate first, save after confirmation.

Stopping at the first error. Report every problem in one pass.

Vague messages. "Invalid data" gives the user nothing to act on. Name the row, column and fix.

No duplicate rule. Decide it deliberately, or a second upload will double your records.

Relying on the template alone. Users will always modify it, so validate regardless.

Skipping undo. A wrong file is a matter of when, not if.

Large files processed in the browser window. Long imports should run in the background with a progress view. See background jobs and queues explained for founders.

When does this design not apply?

If a team imports data once a year, a simpler approach may be enough, such as a developer-assisted load with a checked sample. If the data changes constantly and both systems stay live, a continuous sync is a better fit than a file upload. And if your spreadsheet is the real problem, read when to move from a spreadsheet to custom software.

Frequently asked questions

Should we accept both .xlsx and CSV files?

Accepting both is usually helpful, because users export from many places. Whichever formats you allow, state them on the upload screen and test them with realistic files, including those with extra blank rows, merged cells and odd character encoding.

How many rows should an import handle?

Agree an expected maximum with your build partner, based on how your staff actually work, and test at that size. Show a clear message if a file is too large, and run big imports in the background so the screen stays usable.

Who should be allowed to run imports?

Treat imports as a powerful action, because they can create or change many records at once. Limit them to trusted roles, record who ran each one, and consider an approval step for imports that update existing data.

Can users import data that updates existing records?

Yes, but make it a separate, deliberate mode. Match on a stable identifier, show which fields will change in the preview, and keep the previous values in the import history so the update can be undone.


*Planning an import feature your team can trust? Start a conversation →*

Ready to build?

Let's turn these ideas into your next product.

Start your project