Iniziare

Installazione

Installa da Aspose.Cells a NuGet

NuGet è il modo più semplice per scaricare e installare Aspose.Cells for .NET.

  1. Apri Microsoft Visual Studio e NuGet gestore pacchetti.
  2. Cerca “aspose.cells” per trovare il Aspose.Cells for .NET desiderato.
  3. Clicca su “Installa”, Aspose.Cells for .NET verrà scaricato e referenziato nel tuo progetto. Installa da Aspose Cells a NuGet

Puoi anche scaricarlo dalla pagina web nuget per aspose.cells: Aspose.Cells for .NET NuGet Confezione

Più passo per i dettagli

Installa Aspose.Cells su Windows

  1. Scarica Aspose.Cells.msi dalla seguente pagina: Scarica Aspose.Cells.msi
  2. Fare doppio clic su Aspose Cells msi e seguire le istruzioni per installarlo:

Installa Aspose Cells su Windows

Più passo per i dettagli

Installa Aspose.Cells su Linux

In questo esempio, utilizzo Ubuntu per mostrare come iniziare a utilizzare Aspose.Cells su Linux.

  1. Crea un’applicazione .netcore, denominata “AsposeCellsTest”.
  2. Apri il file “AsposeCellsTest.csproj”, aggiungi le seguenti righe per i riferimenti al pacchetto Aspose.Cells:
      <ItemGroup>
        <PackageReference Include="Aspose.Cells" Version="22.12" />
      </ItemGroup>
  3. Apri il progetto con VSCode su Ubuntu: Installa Aspose Cells su Linux
  4. eseguire test con il seguente codice:
    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
    Aspose.Cells.Workbook wb1 = new Aspose.Cells.Workbook();
    wb1.Worksheets.Add("linux");
    wb1.Worksheets["linux"].Cells[0, 0].Value = "Using Aspose Cells on linux with VS Code.";
    wb1.Save("linux.xlsx");

Nota: Aspose.Cells Per .NetStandard può supportare le tue esigenze su Linux.

Si applica a: NetStandard2.0, NetCore2.1, NetCore3.1, Net5.0, Net6.0 e versione avanzata.

Installa Aspose.Cells su MAC OS

In questo esempio, utilizzo macOS High Sierra per mostrare come iniziare a utilizzare Aspose.Cells su MAC OS.

  1. Crea un’applicazione .netcore, denominata “AsposeCellsTest”.
  2. Aprire l’applicazione con Visual Studio per Mac, quindi installare Aspose Cells tramite NuGet: Installa Aspose Cells su macOS
  3. eseguire il test con il seguente codice:
    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
    Aspose.Cells.Workbook wb1 = new Aspose.Cells.Workbook();
    wb1.Worksheets.Add("macOS");
    wb1.Worksheets["macOS"].Cells[0, 0].Value = "Using Aspose Cells on macOS with Visual Studio For MAC.";
    wb1.Save("macOS.xlsx");
  4. Se è necessario utilizzare funzionalità relative al disegno, installare libgdiplus in macOS, vedere: Come installare libgdiplus su macOS

Nota: Aspose.Cells per .NetStandard può supportare le tue esigenze su MAC OS.

Si applica a: NetStandard2.0, NetCore2.1, NetCore3.1, Net5.0, Net6.0 e versione avanzata.

Esegui Aspose Cells in Docker

Come utilizzare la libreria grafica su piattaforme non Windows con Net6

Aspose.Cells per Net6 ora utilizza SkiaSharp come libreria grafica, come consigliato incomunicato ufficiale del Microsoft . Per ulteriori dettagli sull’utilizzo di Aspose.Cells con NET6, vedereCome eseguire Aspose.Cells per .Net6.

Creazione dell’applicazione Hello World

passaggi seguenti creano l’applicazione Hello World utilizzando Aspose.Cells API:

  1. Se hai una licenza, alloraapplicarlo. Se stai utilizzando la versione di valutazione, salta le righe di codice relative alla licenza.
  2. Crea un’istanza diCartella di lavoro class per creare un nuovo file Excel o aprire un file Excel esistente.
  3. Accedi a qualsiasi cella desiderata di un foglio di lavoro nel file Excel.
  4. Inserisci le paroleHello World! in una cella a cui si accede.
  5. Genera il file Excel Microsoft modificato.

L’implementazione dei passaggi precedenti è dimostrata negli esempi seguenti.

Esempio di codice: creazione di una nuova cartella di lavoro

L’esempio seguente crea una nuova cartella di lavoro da zero, inserisce “Hello World!” nella cella A1 nel primo foglio di lavoro e salva come file Excel.

// 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");

Esempio di codice: apertura di un file esistente

L’esempio seguente apre un file modello Excel Microsoft esistente “Sample.xlsx”, inserisce “Hello World!” nella cella A1 nel primo foglio di lavoro e salva come file Excel.

// 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("Aspose.Cells.lic");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(dataDir + "Sample.xlsx", FileMode.Open);
// Instantiate a Workbook object that represents the existing Excel file
Workbook workbook = new Workbook(fstream);
// Get the reference of "A1" cell from the cells collection of a worksheet
Cell cell = workbook.Worksheets[0].Cells["A1"];
// Put the "Hello World!" text into the "A1" cell
cell.PutValue("Hello World!");
// Save the Excel file
workbook.Save(dataDir + "HelloWorld_out.xlsx");
// Closing the file stream to free all resources
fstream.Close();