Skip to content

Commit a284499

Browse files
waleedlatif1claude
andcommitted
fix(files): lower xlsx preview row cap to 1k and type workbookRef properly
Reduces XLSX_MAX_ROWS from 10,000 to 1,000 to prevent browser sluggishness on large spreadsheets. Types workbookRef with the proper xlsx.WorkBook interface instead of unknown, removing the unsafe cast. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 846214f commit a284499

File tree

1 file changed

+3
-3
lines changed
  • apps/sim/app/workspace/[workspaceId]/files/components/file-viewer

1 file changed

+3
-3
lines changed

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ h1, h2, h3, h4, h5, h6 { margin: 16px 0 8px; }
935935
</style></head><body>${html}</body></html>`
936936
}
937937

938-
const XLSX_MAX_ROWS = 10_000
938+
const XLSX_MAX_ROWS = 1_000
939939

940940
interface XlsxSheet {
941941
name: string
@@ -961,7 +961,7 @@ const XlsxPreview = memo(function XlsxPreview({
961961
const [activeSheet, setActiveSheet] = useState(0)
962962
const [currentSheet, setCurrentSheet] = useState<XlsxSheet | null>(null)
963963
const [renderError, setRenderError] = useState<string | null>(null)
964-
const workbookRef = useRef<unknown>(null)
964+
const workbookRef = useRef<import('xlsx').WorkBook | null>(null)
965965

966966
useEffect(() => {
967967
if (!fileData) return
@@ -1002,7 +1002,7 @@ const XlsxPreview = memo(function XlsxPreview({
10021002
async function parseSheet() {
10031003
try {
10041004
const XLSX = await import('xlsx')
1005-
const workbook = workbookRef.current as ReturnType<typeof XLSX.read>
1005+
const workbook = workbookRef.current!
10061006
const name = sheetNames[activeSheet]
10071007
const sheet = workbook.Sheets[name]
10081008
const allRows = XLSX.utils.sheet_to_json<string[]>(sheet, { header: 1 })

0 commit comments

Comments
 (0)