Caricamento e gestione di file Excel, OpenOffice, Json, Csv and Html
Contents
[
Hide
]
Con Aspose.Cells, è semplice creare, aprire e gestire file Excel, ad esempio, per recuperare dati o utilizzare un modello di progettazione per velocizzare il processo di sviluppo.
Creazione di un nuovo foglio di lavoro
Nell’esempio seguente si crea un nuovo libro di lavoro da zero.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
try | |
{ | |
// Create a License object | |
License license = new License(); | |
// Set the license of Aspose.Cells to avoid the evaluation limitations | |
license.SetLicense(dataDir + "Aspose.Cells.lic"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
// Instantiate a Workbook object that represents Excel file. | |
Workbook wb = new Workbook(); | |
// When you create a new workbook, a default "Sheet1" is added to the workbook. | |
Worksheet sheet = wb.Worksheets[0]; | |
// Access the "A1" cell in the sheet. | |
Cell cell = sheet.Cells["A1"]; | |
// Input the "Hello World!" text into the "A1" cell | |
cell.PutValue("Hello World!"); | |
// Save the Excel file. | |
wb.Save(dataDir + "MyBook_out.xlsx"); |
Apertura e salvataggio di un file
Con Aspose.Cells, è semplice aprire, salvare e gestire file Excel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Opening through Path | |
// Creating a Workbook object and opening an Excel file using its file path | |
Workbook workbook1 = new Workbook(dataDir + "Book1.xlsx"); | |
//Adding new sheet | |
Worksheet sheet = workbook1.Worksheets.Add("MySheet"); | |
//Setting active aheet | |
workbook1.Worksheets.ActiveSheetIndex = 1; | |
//Setting values. | |
Cells cells = sheet.Cells; | |
//Setting text | |
cells["A1"].PutValue("Hello!"); | |
//Setting number | |
cells["A2"].PutValue(1000); | |
//Setting Date Time | |
Cell cell = cells["A3"]; | |
cell.Value = DateTime.Now; | |
Style style = cell.GetStyle(); | |
style.Number = 14; | |
cell.SetStyle(style); | |
//Setting formula | |
cells["A4"].Formula = "=SUM(A1:A3)"; | |
//Saving the workbook to disk. | |
workbook1.Save(dir + "dest.xlsx"); |
Argomenti avanzati
- Diversi modi per aprire i file
- Filtra i nomi definiti durante il caricamento del foglio di lavoro
- Filtra gli oggetti durante il caricamento del foglio di lavoro o del foglio di calcolo
- Filtrare il tipo di dati durante il caricamento del libro di lavoro da file modello
- Ottieni avvisi durante il caricamento del file Excel
- Carica il file Excel di origine senza grafici
- Carica fogli di lavoro specifici in un libro di lavoro
- Carica il libro di lavoro con il formato di carta della stampante specificato
- Apertura di file di diverse versioni di Microsoft Excel
- Apertura di file con formati diversi
- Ottimizzazione dell’utilizzo della memoria durante il lavoro con file grandi che contengono grandi set di dati
- Leggi i fogli di calcolo di Numbers sviluppati da Apple Inc. utilizzando Aspose.Cells
- Interrompere la conversione o il caricamento utilizzando InterruptMonitor quando sta impiegando troppo tempo
- Utilizzo di API LightCells
- Convertire CSV in JSON
- Converti-Excel-in-JSON
- Convertire JSON in CSV
- Converti-JSON-in-Excel
- Converti-Excel-in-Html