Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(files): lower xlsx preview row cap to 1k and type workbookRef pro…
…perly

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>
  • Loading branch information
waleedlatif1 and claude committed Apr 5, 2026
commit a284499de3095712a7de1b691639961d3e775e62
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ h1, h2, h3, h4, h5, h6 { margin: 16px 0 8px; }
</style></head><body>${html}</body></html>`
}

const XLSX_MAX_ROWS = 10_000
const XLSX_MAX_ROWS = 1_000
Comment thread
waleedlatif1 marked this conversation as resolved.

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

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