Excel'i CSV,TSV ve Txt'ye dönüştürün
Çalışma Kitabını Metne veya CSV Formatına Kaydetme
Bazen, birden çok çalışma sayfası içeren bir çalışma kitabını metin biçimine dönüştürmek veya kaydetmek istersiniz. Metin biçimleri için (örneğin TXT, TabDelim, CSV, vb.), hem Microsoft Excel hem de Aspose.Cells varsayılan olarak yalnızca etkin çalışma sayfasının içeriğini kaydeder.
Aşağıdaki kod örneği, tüm çalışma kitabının metin biçiminde nasıl kaydedileceğini açıklar. Herhangi bir sayıda çalışma sayfası içeren herhangi bir Microsoft Excel veya OpenOffice elektronik tablo dosyası (yani XLS, XLSX, XLSM, XLSB, ODS vb.) olabilecek kaynak çalışma kitabını yükleyin.
Kod yürütüldüğünde, çalışma kitabındaki tüm sayfaların verilerini TXT biçimine dönüştürür.
Dosyanızı CSV’e kaydetmek için aynı örneği değiştirebilirsiniz. Varsayılan olarak,**TxtSaveOptions.Separator**virgüldür, bu nedenle CSV biçiminde kaydediyorsanız ayırıcı belirtmeyin.
// 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); | |
// Load your source workbook | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Text save options. You can use any type of separator | |
TxtSaveOptions opts = new TxtSaveOptions(); | |
opts.Separator = '\t'; | |
opts.ExportAllSheets = true; | |
// Save entire workbook data into file | |
workbook.Save(dataDir + "out.txt", opts); |
Metin Dosyalarını Özel Ayırıcıyla Kaydetme
Metin dosyaları biçimlendirme olmadan elektronik tablo verileri içerir. Dosya, verileri arasında bazı özelleştirilmiş sınırlayıcılara sahip olabilen bir tür düz metin dosyasıdır.
// 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); | |
string filePath = dataDir + "Book1.xlsx"; | |
// Create a Workbook object and opening the file from its path | |
Workbook wb = new Workbook(filePath); | |
// Instantiate Text File's Save Options | |
TxtSaveOptions options = new TxtSaveOptions(); | |
// Specify the separator | |
options.Separator = Convert.ToChar(";"); | |
// Save the file with the options | |
wb.Save(dataDir + "output.csv", options); | |