Tablolar ve Aralıklar

Giriş

Bazen Microsoft Excel’de bir tablo oluşturursunuz ve onunla gelen tablo işlevleriyle çalışmak istemezsiniz. Bunun yerine, bir tablo gibi görünen bir şey istersiniz. Biçimlendirmeyi kaybetmeden bir tabloda veri tutmak için tabloyu normal bir veri aralığına dönüştürün. Aspose.Cells, Microsoft Excel’in tablo ve liste nesneleri için bu özelliği destekler.

Microsoft Excel Kullanımı

Dönüştürülecek Aralığı Belirt özelliğini kullanarak bir tabloyu biçimlendirmeyi kaybetmeden hızlıca bir aralığa dönüştürmek için aşağıdaki adımları izleyin. Microsoft Excel 2007/2010’da:

  1. Tablonun herhangi bir yerine tıklayın ve etkin hücrenin bir tablo sütununda olduğundan emin olun.
  2. Tasarım sekmesinde, Araçlar grubunda, Dönüştür‘ü tıklayın.

Aspose.Cells Kullanımı

// 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);
// Open an existing file that contains a table/list object in it
Workbook wb = new Workbook(dataDir + "book1.xlsx");
// Convert the first table/list object (from the first worksheet) to normal range
wb.Worksheets[0].ListObjects[0].ConvertToRange();
// Save the file
wb.Save(dataDir + "output.xlsx");

Tablo, Aralığı Seçenekleri ile Aralığı Dönüştürme

Aspose.Cells, TableToRangeOptions sınıfı aracılığıyla Tablo’yu Aralığa dönüştürürken ek seçenekler sağlar. TableToRangeOptions sınıfı, belirtilen satır dizinine kadar tablo biçimlendirmesini korumanızı ve geri kalan biçimlendirmeyi kaldırmanızı sağlayan LastRow özelliğini sağlar.

Aşağıda verilen örnek kod, TableToRangeOptions sınıfının kullanımını göstermektedir.

// 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);
// Open an existing file that contains a table/list object in it
Workbook workbook = new Workbook(dataDir + "book1.xlsx");
TableToRangeOptions options = new TableToRangeOptions();
options.LastRow = 5;
// Convert the first table/list object (from the first worksheet) to normal range
workbook.Worksheets[0].ListObjects[0].ConvertToRange(options);
// Save the file
workbook.Save(dataDir + "output.xlsx");