fix(import): preserve empty strings in Excel by default

Closes #5329
This commit is contained in:
t8y2 committed 2026-08-10 09:54:30 +08:00
1 parent a1918ec8c2
commit 0c9b6c7e1d
4 files changed
+57 -4

No files matched your search

@@ -15,6 +15,7 @@ import { useToast } from "@/composables/useToast";
import {
autoMapImportColumns,
buildTableImportParseOptions,
defaultTableImportEmptyStringAsNull,
formatTableImportElapsed,
nextTableImportWizardStep,
previousTableImportWizardStep,
@@ -90,7 +91,7 @@ const titleRow = ref(1);
const dataStartRow = ref(2);
const lastDataRow = ref(0);
const trimValues = ref(false);
const emptyStringAsNull = ref(true);
const emptyStringAsNull = ref(defaultTableImportEmptyStringAsNull(sourceFormat.value));
const selectedSheet = ref("");
const jsonShape = ref<api.TableImportJsonShape>("auto");
const previewLimit = ref(50);
@@ -250,7 +251,7 @@ function resetState() {
dataStartRow.value = 2;
lastDataRow.value = 0;
trimValues.value = false;
emptyStringAsNull.value = true;
emptyStringAsNull.value = defaultTableImportEmptyStringAsNull(sourceFormat.value);
selectedSheet.value = "";
jsonShape.value = "auto";
previewLimit.value = 50;
@@ -519,6 +520,7 @@ function assignSelectedSource(source: string | File) {
errorMessage.value = "";
const name = typeof source === "string" ? source : source.name;
sourceFormat.value = detectFormat(name);
emptyStringAsNull.value = defaultTableImportEmptyStringAsNull(sourceFormat.value);
if (!newTableName.value.trim()) {
newTableName.value = suggestedTableName(name);
}
@@ -554,9 +556,11 @@ async function prepareBatchSources(sources: ImportSource[]) {
errorMessage.value = "";
const tasks: BatchImportTask[] = [];
const usedNames = new Set<string>();
const formats = sources.map((source) => detectFormat(sourceName(source)));
emptyStringAsNull.value = formats.length && formats.every((format) => format === formats[0]) ? defaultTableImportEmptyStringAsNull(formats[0]!) : true;
try {
for (const source of sources) {
const format = detectFormat(sourceName(source));
for (const [index, source] of sources.entries()) {
const format = formats[index]!;
const initialPreview = await api.previewTableImportFile(source, {
sourceFormat: format,
parseOptions: taskParseOptions(format),