入門

インストール

Aspose.Cells から NuGet をインストールします。

NuGet は、Aspose.Cells for .NET をダウンロードしてインストールする最も簡単な方法です。

  1. Microsoft Visual Studio と NuGet パッケージ マネージャーを開きます。
  2. 「aspose.cells」を検索して、目的の Aspose.Cells for .NET を見つけます。
  3. 「インストール」をクリックすると、Aspose.Cells for .NET がダウンロードされ、プロジェクトで参照されます。 インストール Aspose Cells ~ NuGet

aspose.cells の nuget Web ページからダウンロードすることもできます。 Aspose.Cells for .NET NuGet パッケージ

詳細については、さらに手順を実行してください

Windows に Aspose.Cells をインストールします。

  1. 次のページから Aspose.Cells.msi をダウンロードします。 Aspose.Cells.msi をダウンロード
  2. Aspose Cells msi をダブルクリックし、指示に従ってインストールします。

Windows に Aspose Cells をインストール

詳細については、さらに手順を実行してください

Linux に Aspose.Cells をインストールします。

この例では、Ubuntu を使用して、Linux で Aspose.Cells の使用を開始する方法を示します。

  1. 「AsposeCellsTest」という名前の .netcore アプリケーションを作成します。
  2. ファイル「AsposeCellsTest.csproj」を開き、Aspose.Cells パッケージ参照用に次の行を追加します。
      <ItemGroup>
        <PackageReference Include="Aspose.Cells" Version="22.12" />
      </ItemGroup>
  3. Ubuntu で VSCode を使用してプロジェクトを開きます。 Linux に Aspose Cells をインストール
  4. 次のコードでテストを実行します。
    // 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");

注: .NetStandard の場合、Aspose.Cells は Linux での要件をサポートできます。

適用対象: NetStandard2.0、NetCore2.1、NetCore3.1、Net5.0、Net6.0、および高度なバージョン。

MAC OS に Aspose.Cells をインストール

この例では、macOS High Sierra を使用して、MAC OS で Aspose.Cells の使用を開始する方法を示します。

  1. 「AsposeCellsTest」という名前の .netcore アプリケーションを作成します。
  2. Visual Studio for Mac でアプリケーションを開き、Aspose Cells から NuGet をインストールします。 macOS に Aspose Cells をインストール
  3. 次のコードでテストを実行します。
    // 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. 描画関連の機能を使用する必要がある場合は、macOS に libgdiplus をインストールしてください。以下を参照してください。 macOS に libgdiplus をインストールする方法

注: Aspose.Cells .NetStandard は、MAC OS での要件をサポートできます。

適用対象: NetStandard2.0、NetCore2.1、NetCore3.1、Net5.0、Net6.0、および高度なバージョン。

Docker で Aspose Cells を実行

Windows 以外のプラットフォームで Net6 を使用してグラフィック ライブラリを使用する方法

Net6 の Aspose.Cells では、推奨されているように、SkiaSharp をグラフィック ライブラリとして使用するようになりました。Microsoftの公式声明 NET6 で Aspose.Cells を使用する方法の詳細については、次を参照してください。.Net6 で Aspose.Cells を実行する方法.

Hello World アプリケーションの作成

以下の手順では、Aspose.Cells API を使用して Hello World アプリケーションを作成します。

  1. 免許をお持ちの方は、それを適用する. 評価版を使用している場合は、ライセンス関連のコード行をスキップしてください。
  2. のインスタンスを作成しますワークブッククラスを使用して、新しい Excel ファイルを作成するか、既存の Excel ファイルを開きます。
  3. Excel ファイル内のワークシートの目的のセルにアクセスします。
  4. 単語を挿入する**Hello World!**アクセスされたセルに。
  5. 変更された Microsoft Excel ファイルを生成します。

上記の手順の実装は、以下の例で示されています。

コード サンプル: 新しいワークブックの作成

次の例では、新しいワークブックをゼロから作成し、“Hello World!” を挿入します。最初のワークシートのセル A1 に入力し、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");

コード サンプル: 既存のファイルを開く

次の例では、既存の Microsoft Excel テンプレート ファイル “Sample.xlsx” を開き、“Hello World!” を挿入します。最初のワークシートのセル A1 に入力し、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();