Excel、OpenOffice、Json、Csv、および Html ファイルの読み込みと管理
Contents
[
Hide
]
Aspose.Cells を使用すると、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 | |
// 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"); |
ファイルを開いて保存する
Aspose.Cells を使用すると、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"); |
先行トピック
- ファイルを開くさまざまな方法
- ワークブックの読み込み中に定義された名前をフィルター処理する
- ワークブックまたはワークシートの読み込み中にオブジェクトをフィルタリングする
- テンプレート ファイルからワークブックを読み込む際のデータの種類のフィルタリング
- Excel ファイルの読み込み中に警告を受け取る
- グラフなしでソース Excel ファイルを読み込む
- ワークブックに特定のワークシートをロードする
- 指定したプリンター用紙サイズのワークブックを読み込む
- 異なる Microsoft Excel バージョンのファイルを開く
- 異なる形式のファイルを開く
- 大規模なデータセットを含む大きなファイルを操作する際のメモリ使用量の最適化
- 読み取り Numbers スプレッドシート Apple Inc. が Aspose.Cells を使用して開発
- 時間がかかりすぎる場合は、InterruptMonitor を使用して変換またはロードを停止します
- LightCells の使用 API