テーブルおよび範囲
Contents
[
Hide
]
紹介
Microsoft Excelでテーブルを作成し、それをそのままの機能で使用しない場合があります。代わりに、テーブルの機能を失わずに、テーブルのように見えるものが欲しいことがあります。フォーマットを維持するため、テーブルのデータを通常のデータ範囲に変換することができます。Aspose.Cellsは、テーブルとリストオブジェクトのためのこのMicrosoft Excelの機能をサポートしています。
Microsoft Excel の使用
表をフォーマットを保持したまま範囲に素早く変換するには、範囲に変換 機能を使用します。Microsoft Excel 2007/2010では:
- 表内のどこかをクリックして、アクティブなセルが表の列内にあることを確認します。
- デザイン タブの ツール グループで、範囲に変換 をクリックします。
表を範囲に変換した後は、表の機能は利用できなくなります。たとえば、行ヘッダーにはソートとフィルターの矢印が含まれなくなり、数式で使用されたテーブル名を参照する構造化参照は通常のセル参照に変わります。
Aspose.Cellsの使用
次のコードスニペットは、Aspose.Cellsを使用して同じ機能を示しています。
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-C | |
Aspose::Cells::Startup(); | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
// Instantiate a Workbook object and open an Excel file | |
Workbook workbook(dirPath + u"sample.xlsx"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.GetWorksheets().Get(0); | |
// Get the List objects collection in the first worksheet. | |
ListObjectCollection listObjects = worksheet.GetListObjects(); | |
// Convert the first table/list object (from the first worksheet) to normal range | |
listObjects.Get(0).ConvertToRange(); | |
// Saving the Excel file | |
workbook.Save(outPath + u"ConvertTableToRange_out.xls"); | |
Aspose::Cells::Cleanup(); |