テーブルおよび範囲

紹介

Microsoft Excelでテーブルを作成し、それをそのままの機能で使用しない場合があります。代わりに、テーブルの機能を失わずに、テーブルのように見えるものが欲しいことがあります。フォーマットを維持するため、テーブルのデータを通常のデータ範囲に変換することができます。Aspose.Cellsは、テーブルとリストオブジェクトのためのこのMicrosoft Excelの機能をサポートしています。

Microsoft Excel の使用

表をフォーマットを保持したまま範囲に素早く変換するには、範囲に変換 機能を使用します。Microsoft Excel 2007/2010では:

  1. 表内のどこかをクリックして、アクティブなセルが表の列内にあることを確認します。
  2. デザイン タブの ツール グループで、範囲に変換 をクリックします。

Aspose.Cellsの使用

次のコードスニペットは、Aspose.Cellsを使用して同じ機能を示しています。

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