Dosyaları Açmanın Farklı Yolları

Yol Yoluyla Dosya Açma

Geliştiriciler, dosya yolunu kullanarak bir Microsoft Excel dosyasını yerel bilgisayarda belirterek açabilirler.**Çalışma Kitabı**sınıf oluşturucu Yapıcıdaki yolu basit bir şekilde iletinsicim. Aspose.Cells, dosya biçimi türünü otomatik olarak algılar.

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook
# Opening a File via a Path
# The path to the documents directory.
dataDir = ""
# Opening through Path
# Creating a Workbook object and opening an Excel file using its file path
workbook = Workbook(dataDir + "Input.xlsx")
print("Workbook opened using path successfully!")
jpype.shutdownJVM()

Akış Yoluyla Dosya Açma

Bir Excel dosyasını akış olarak açmak da kolaydır. Bunu yapmak için, yapıcının aşırı yüklenmiş bir sürümünü kullanın.Tampon Akışıdosyayı içeren nesne.

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook
from jpype import java
fis = java.io.FileInputStream("Input.xlsx")
workbook = Workbook(fis)
print("Workbook opened using stream successfully!!")
workbook.save("Output.pdf")
fis.close()
jpype.shutdownJVM()

Yalnızca Veri İçeren Bir Dosyayı Açma

Yalnızca veri içeren bir dosyayı açmak için,LoadOptions ve**LoadFilter**yüklenecek şablon dosyası için sınıfların ilgili özniteliklerini ve seçeneklerini ayarlamak için sınıflar.

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook, LoadOptions, LoadFormat, LoadFilter, LoadDataFilterOptions
# Opening a File with Data only
# The path to the documents directory.
dataDir = ""
# Load only specific sheets with data and formulas
# Other objects, items etc. would be discarded
# Instantiate LoadOptions specified by the LoadFormat
loadOptions = LoadOptions(LoadFormat.XLSX)
# Set LoadFilter property to load only data & cell formatting
loadOptions.setLoadFilter(LoadFilter(LoadDataFilterOptions.CELL_DATA))
# Create a Workbook object and opening the file from its path
workbook = Workbook(dataDir + "Input.xlsx", loadOptions)
print("File data imported successfully!")
jpype.shutdownJVM()