Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sergio-salcedo-dev/excel-product-manager/llms.txt
Use this file to discover all available pages before exploring further.
Preoc Product Manager uses the xlsx library to read and write spreadsheet files, giving you a seamless bridge between the in-browser catalog and the spreadsheets your team already works with. You can import a bulk product list from any .xlsx or .xls file to instantly populate the catalog, and export your entire current catalog as a downloadable productos.xlsx file at any time — no server required.
Importing from Excel
To import products, click Importar Excel in the left sidebar. A native file picker opens — select any .xlsx or .xls file from your device. The file is read entirely in the browser via the FileReader API; nothing is uploaded to a server.
ExcelService.parseExcel reads the first sheet of the workbook and maps each data row to a Product object. The parser accepts both English and Spanish column header names, making it easy to re-import files that were previously exported from Preoc (which uses Spanish headers) or prepared from scratch in English.
Expected Column Headers
| Field | Accepted Header Names | Notes |
|---|
id | id, ID | Defaults to prod-{Date.now()}-{index} if missing |
code | code, Código, Codigo | Falls back to empty string if absent |
description | description, Descripción, Descripcion | Falls back to empty string if absent |
unit | unit, Unidad | Defaults to ud if missing |
price | price, Precio | Parsed as parseFloat; defaults to 0 |
category | category, Categoría, Categoria | Defaults to General if missing |
Sample Excel Layout
The table below shows what a correctly structured import sheet looks like:
| Código | Descripción | Unidad | Precio | Categoría |
|---|
| MT-001 | Cemento Portland Tipo I - Saco 50kg | sac | 9.50 | Materiales |
| MO-001 | Oficial de Primera - Hora | h | 24.50 | Mano de Obra |
| MQ-001 | Hormigonera Eléctrica 150L - Alquiler día | día | 12.00 | Maquinaria |
| IN-001 | Cable Cobre 2.5mm Libre Halógenos - 100m | rol | 65.00 | Instalaciones |
The ID column is optional — the importer generates a unique ID for any row where it is missing or blank.
Importing replaces the entire current catalog. All existing products in
the browser are discarded and replaced with the rows from the imported file.
Export your current catalog first if you need to preserve any existing
products before importing a new file.
On a successful import, a green alert banner confirms: “Archivo procesado correctamente.” The view resets to page 1 of the newly imported catalog. If the file cannot be parsed (wrong format, corrupted file, etc.), a red error alert is shown instead: “Error al procesar el Excel. Asegúrese de que el formato sea correcto.”
ExcelService.parseExcel API
ExcelService.parseExcel(file: File): Promise<Product[]>
Accepts a File object (from an <input type="file"> change event) and returns a Promise that resolves with an array of Product objects. Internally it:
- Reads the file as an
ArrayBuffer using FileReader.readAsArrayBuffer.
- Wraps the result in a
Uint8Array and passes it to XLSX.read(data, { type: 'array' }) to parse the workbook.
- Targets
workbook.SheetNames[0] — always the first sheet.
- Converts the sheet to a JSON array with
XLSX.utils.sheet_to_json().
- Maps each row through the header-alias lookup table above, applying defaults where fields are missing.
The promise rejects if the file cannot be read or if XLSX.read() throws.
Exporting to Excel
To export your catalog, click Exportar Datos in the left sidebar. The browser immediately triggers a file download — no dialog or configuration needed.
The exported file is named productos.xlsx by default and contains a single sheet called Productos. The export always includes all products currently in the catalog, not just the products visible on the current page.
Output Columns
The exported sheet uses Spanish column headers to match the accepted import aliases, enabling round-trip workflows:
| Column Header | Source Field | Type |
|---|
ID | product.id | String |
Código | product.code | String |
Descripción | product.description | String |
Unidad | product.unit | String |
Precio | product.price | Number |
Categoría | product.category | String |
ExcelService.exportToExcel API
ExcelService.exportToExcel(products: Product[], fileName: string = 'productos.xlsx'): void
Accepts the array of products to export and an optional file name (defaults to 'productos.xlsx'). Internally it:
- Maps the
Product array to plain objects with the Spanish column headers shown above.
- Converts the array to a worksheet with
XLSX.utils.json_to_sheet().
- Creates a new workbook with
XLSX.utils.book_new() and appends the sheet as "Productos" using XLSX.utils.book_append_sheet().
- Triggers a browser download with
XLSX.writeFile().
You can round-trip your data freely: click Exportar Datos to download the
current catalog, edit prices or descriptions in Excel, then click Importar
Excel to reload the updated file. The Spanish column headers (Código,
Descripción, Categoría, etc.) produced by the exporter are all valid
import aliases, so no reformatting is needed between export and re-import.