Cargando y gestionando archivos de Excel, OpenOffice, Json, Csv y Html
Contents
[
Hide
]
Con Aspose.Cells, es simple crear, abrir y gestionar archivos de Excel, por ejemplo, para obtener datos, o usar una plantilla de diseñador para acelerar el proceso de desarrollo.
Creando un libro de trabajo nuevo
El siguiente ejemplo crea un nuevo libro de trabajo desde cero.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const licensePath = path.join(dataDir, "Aspose.Cells.lic");
try {
// Create a License object
const license = new AsposeCells.License();
// Set the license of Aspose.Cells to avoid the evaluation limitations
license.setLicense(licensePath);
} catch (ex) {
console.log(ex.message);
}
// Instantiate a Workbook object that represents Excel file.
const wb = new AsposeCells.Workbook();
// When you create a new workbook, a default "Sheet1" is added to the workbook.
const sheet = wb.getWorksheets().get(0);
// Access the "A1" cell in the sheet.
const cell = sheet.getCells().get("A1");
// Input the "Hello World!" text into the "A1" cell
cell.putValue("Hello World!");
// Save the Excel file.
wb.save(path.join(dataDir, "MyBook_out.xlsx"));
Abrir y guardar un archivo
Con Aspose.Cells, es fácil abrir, guardar y gestionar archivos de Excel.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Opening through Path
// Creating a Workbook object and opening an Excel file using its file path
const workbook1 = new AsposeCells.Workbook(path.join(dataDir, "Book1.xlsx"));
// Adding new sheet
const sheet = workbook1.getWorksheets().add("MySheet");
// Setting active sheet
workbook1.getWorksheets().setActiveSheetIndex(1);
// Setting values.
const cells = sheet.getCells();
// Setting text
cells.get("A1").putValue("Hello!");
// Setting number
cells.get("A2").putValue(1000);
// Setting Date Time
const cell = cells.get("A3");
cell.putValue(new Date());
const style = cell.getStyle();
style.setNumber(14);
cell.setStyle(style);
// Setting formula
cells.get("A4").setFormula("=SUM(A1:A3)");
// Saving the workbook to disk.
workbook1.save(path.join(dataDir, "dest.xlsx"));
Temas avanzados
- Diferentes formas de abrir archivos
- Filtrar nombres definidos al cargar el libro de trabajo
- Filtrar objetos al cargar el libro de trabajo o de la hoja de cálculo
- Filtrar el tipo de datos al cargar el libro de trabajo desde un archivo de plantilla
- Obtener advertencias al cargar archivo de Excel
- Cargar archivo de Excel fuente sin gráficos
- Cargar hojas de cálculo específicas en un libro de trabajo
- Cargar libro de trabajo con tamaño de papel de impresora especificado
- Abrir archivos de diferentes versiones de Microsoft Excel
- Abriendo Archivos con Diferentes Formatos
- Optimización del uso de memoria al trabajar con archivos grandes que contengan conjuntos de datos extensos
- Leer Hojas de cálculo Numbers desarrolladas por Apple Inc. usando Aspose.Cells
- Detener la conversión o carga utilizando InterruptMonitor cuando está tardando demasiado
- Usar la API LightCells
- Convertir CSV a JSON
- Convertir Excel a JSON
- Convertir JSON a CSV
- Convertir JSON a Excel
- Convertir Excel a Html