Farklı Formatlardaki Dosyaları Açma
Aspose.Cells for Python via .NET kullanarak farklı formatlarda dosyaları açabilirsiniz. Aspose.Cells for Python via .NET, Microsoft Excel elektronik tabloları (XLS, XLSX, XLSM, XLSB), SpreadsheetML, Virgüllü ayrılmış değerler (CSV), Sekmeli Ayrılmış veya Sekmeli Ayrılmış Değerler (TSV) dosyaları gibi birçok dosya formatını açabilir.
Desteklenen tüm dosya formatlarını öğrenmeniz gerekiyorsa lütfen aşağıdaki sayfalara bakın: Desteklenen Dosya Biçimleri
Farklı Biçimlerde Dosyaları Açma
Aspose.Cells for Python via .NET, geliştiricilerin SpreadsheetML, Virgüllü ayrılmış değerler (CSV), Sekme Ayrılmış veya Sekme Ayrılmış Değerler (TSV), ODS dosyaları gibi farklı formatlarda elektronik tablo dosyalarını açmasına olanak tanır. Bu tür dosyaları açmak için, geliştiriciler aynı yöntemleri kullanabilirler; farklı Microsoft Excel sürümleri için dosyaları açmak gibi.
Elektronik Tablo Dili (SpreadsheetML) Dosyalarını Açma
SpreadsheetML dosyaları, elektronik tabloların biçimlendirme, formüller vb. gibi tüm bilgilerini içeren XML temsilleridir. Microsoft Excel XP’den beri, Microsoft Excel’e bir XML dışa aktarma seçeneği eklenmiştir. Bu seçenek elektronik tablolarınızı SpreadsheetML dosyalarına dışa aktarır.
from aspose.cells import LoadFormat, LoadOptions, 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(".") | |
# Opening SpreadsheetML Files | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions3 = LoadOptions(LoadFormat.SPREADSHEET_ML) | |
# Create a Workbook object and opening the file from its path | |
wbSpreadSheetML = Workbook(dataDir + "Book3.xml", loadOptions3) | |
print("SpreadSheetML file opened successfully!") |
HTML Dosyalarını Açma
Aspose.Cells for Python via .NET, HTML dosyasını Workbook nesnesine açmanıza izin verir. HTML dosyasının, Microsoft Excel uyumlu olması gerekir, yani MS-Excel tarafından açılabilmelidir.
from aspose.cells import HtmlLoadOptions, LoadFormat, 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(".") | |
filePath = dataDir + "Book1.html" | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions = HtmlLoadOptions(LoadFormat.HTML) | |
# Create a Workbook object and opening the file from its path | |
wb = Workbook(filePath, loadOptions) | |
# Save the MHT file | |
wb.save(filePath + "output.xlsx") |
CSV Dosyalarını Açma
Virgülle Ayrılmış Değerler (CSV) dosyaları, değerlerin virgülle ayrıldığı kayıtları içerir. Veri, her sütunun virgül karakteriyle ayrıldığı ve çift tırnak karakteriyle alıntılanmış bir tablo olarak saklanır. Bir alan değeri çift tırnak karakteri içeriyorsa, çift tırnak karakteriyle kaçış yapılır. Elektronik tablo verilerini CSV’ye aktarmak için Microsoft Excel’i de kullanabilirsiniz.
from aspose.cells import LoadFormat, LoadOptions, 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(".") | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions4 = LoadOptions(LoadFormat.CSV) | |
# Create a Workbook object and opening the file from its path | |
wbCSV = Workbook(dataDir + "Book_CSV.csv", loadOptions4) | |
print("CSV file opened successfully!") |
CSV Dosyalarını Açma ve Geçersiz Karakterleri Değiştirme
Excel’de, özel karakterler içeren CSV dosyası açıldığında, karakterler otomatik olarak değiştirilir. Aynı işlemi Aspose.Cells for Python via .NET API de yapar ve aşağıda verilen kod örneğinde gösterilmiştir.
from aspose.cells import LoadDataFilterOptions, LoadFilter, TxtLoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
filename = sourceDir + "[20180220142533][ASPOSE_CELLS_TEST].csv" | |
options = TxtLoadOptions() | |
options.separator = ';' | |
options.load_filter = LoadFilter(LoadDataFilterOptions.CELL_DATA) | |
options.check_excel_restriction = False | |
options.convert_numeric_data = False | |
options.convert_date_time_data = false | |
# Load CSV file | |
workbook = Workbook(filename, options) | |
print(workbook.worksheets[0].name) | |
print(len(workbook.worksheets[0].name)) | |
print("CSV file opened successfully!") |
Sekmeyle Ayrılmış Dosyaları Açma
Sekmeyle Ayrılmış (Metin) dosyası biçimlendirme olmadan elektronik tablo verileri içerir. Veri, tablolar ve elektronik tablolar gibi satırlar ve sütunlar halinde düzenlenir. Temelde, sekmeyle ayrılmış dosya, her sütun arasında bir sekme olan bir tür düz metin dosyasıdır.
from aspose.cells import LoadFormat, LoadOptions, 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(".") | |
# Opening Tab Delimited Files | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions5 = LoadOptions(LoadFormat.TAB_DELIMITED) | |
# Create a Workbook object and opening the file from its path | |
wbTabDelimited = Workbook(dataDir + "Book1TabDelimited.txt", loadOptions5) | |
print("Tab delimited file opened successfully!") |
Sekmeyle Ayrılmış Değerler (TSV) Dosyalarını Açma
Sekmeyle ayrılmış değerler (TSV) dosyası biçimlendirme olmadan elektronik tablo verileri içerir. Veri, tablolar ve elektronik tablolar gibi satırlar ve sütunlar halinde düzenlenir. Veri, tablo ve elektronik tablo gibi satırlar ve sütunlar halinde düzenlenir.
from aspose.cells import LoadFormat, LoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions = LoadOptions(LoadFormat.TSV) | |
# Create a Workbook object and opening the file from its path | |
workbook = Workbook(sourceDir + "SampleTSVFile.tsv", loadOptions) | |
# Using the Sheet 1 in Workbook | |
worksheet = workbook.worksheets[0] | |
# Accessing a cell using its name | |
cell = worksheet.cells.get("C3") | |
print("Cell Name: " + cell.name + " Value: " + cell.string_value) |
SXC Dosyalarını Açma
StarOffice Calc, Microsoft Excel’e benzeyen ve formüller, grafikler, fonksiyonlar ve makroları destekleyen bir yazılımdır. Bu yazılım ile oluşturulan elektronik tablolar SXC uzantısı ile kaydedilir. SXC dosyası, OpenOffice.org Calc elektronik tablo dosyaları için de kullanılır. Aspose.Cells for Python via .NET, SXC dosyalarını aşağıdaki kod örneğiyle okuyabilir.
from aspose.cells import LoadFormat, LoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions = LoadOptions(LoadFormat.SXC) | |
# Create a Workbook object and opening the file from its path | |
workbook = Workbook(sourceDir + "SampleSXC.sxc", loadOptions) | |
# Using the Sheet 1 in Workbook | |
worksheet = workbook.worksheets[0] | |
# Accessing a cell using its name | |
cell = worksheet.cells.get("C3") | |
print("Cell Name: " + cell.name + " Value: " + cell.string_value) |
FODS Dosyalarını Açma
FODS dosyası, sıkıştırma olmadan OpenDocument XML formatında kaydedilmiş elektronik tablodur. Aspose.Cells for Python via .NET, FODS dosyalarını aşağıdaki kod örneğiyle okuyabilir.
from aspose.cells import LoadFormat, LoadOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
# Instantiate LoadOptions specified by the LoadFormat. | |
loadOptions = LoadOptions(LoadFormat.FODS) | |
# Create a Workbook object and opening the file from its path | |
workbook = Workbook(sourceDir + "SampleFods.fods", loadOptions) | |
print("FODS file opened successfully!") |