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 for Python via .NET, Microsoft Excel’in tablo ve liste nesneleri özelliğini 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 for Python via .NET Kullanılarak

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Open an existing file that contains a table/list object in it
wb = Workbook(dataDir + "book1.xlsx")
# Convert the first table/list object (from the first worksheet) to normal range
wb.worksheets[0].list_objects[0].convert_to_range()
# Save the file
wb.save(dataDir + "output.xlsx")

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

Aspose.Cells for Python via .NET, Tabloyu Aralığa dönüştürürken ek seçenekler sağlar; TableToRangeOptions sınıfı aracılığıyla yapılabilir. TableToRangeOptions sınıfı, last_row özelliğiyle tablonun son satırını belirlemenize izin verir. Bu ayar ile formatlama, belirlenen satıra kadar korunur ve kalan formatlama kaldırılır.

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

from aspose.cells import Workbook
from aspose.cells.tables import TableToRangeOptions
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Open an existing file that contains a table/list object in it
workbook = Workbook(dataDir + "book1.xlsx")
options = TableToRangeOptions()
options.last_row = 5
# Convert the first table/list object (from the first worksheet) to normal range
workbook.worksheets[0].list_objects[0].convert_to_range(options)
# Save the file
workbook.save(dataDir + "output.xlsx")