Carica o importa file CSV con formule

Contents
[ ]

Il codice seguente illustra come è possibile caricare e importare un file CSV con formule. È possibile utilizzare qualsiasi file CSV. A scopo illustrativo, utilizziamo il semplice file CSV che contiene questi dati. Come puoi vedere contiene una formula.

 300,500,=Sum(A1:B1)
// 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);
TxtLoadOptions opts = new TxtLoadOptions();
opts.Separator = ',';
opts.HasFormula = true;
// Load your CSV file with formulas in a Workbook object
Workbook workbook = new Workbook(dataDir + "sample.csv", opts);
// You can also import your CSV file like this
// The code below is importing CSV file starting from cell D4
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells.ImportCSV(dataDir + "sample.csv", opts, 3, 3);
// Save your workbook in Xlsx format
workbook.Save(dataDir + "output_out.xlsx");

Il codice carica prima il file CSV, poi lo importa nuovamente nella cella D4. Infine, salva l’oggetto del foglio di lavoro in formato XSLX. Il file XLSX in output appare così. Come si vede, le celle C3 e F4 contengono una formula e il suo risultato è 800.

todo:image_alt_text