Tabstoppgetrenntes Dateiformat lesen und schreiben
Mögliche Verwendungsszenarien
Microsoft Excel unterstützt viele Formate wie XLS, XLSX, XLSM, XLSB, CSV, tabstoppgetrennt usw. Aspose.Cells unterstützt ebenfalls viele dieser Formate. Dieser Artikel erläutert, wie die Excel-Datei im tabstoppgetrennten Format mit Aspose.Cells gelesen und geschrieben wird.
Tabstoppgetrenntes Dateiformat lesen und schreiben
Das folgende Beispiel lädt die [Quell-Tabstopp-getrennte Datei (23166997.txt)] und liest ihre Zelle A1 und kopiert dann ihren Inhalt in Zelle C4 und speichert sie als [Ausgabetabstoppgetrennte Datei (23166996.txt)].
Beispielcode
Aspose::Cells::Startup(); | |
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
U16String dirPath(u"..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
U16String outPath(u"..\\Data\\Output\\"); | |
//Path of input tab delimited file | |
U16String srcReadWriteTabDelimited = dirPath + u"srcReadWriteTabDelimited.txt"; | |
//Path of output tab delimited file | |
U16String outReadWriteTabDelimited = outPath + u"outReadWriteTabDelimited.txt"; | |
//Read source tab delimited file | |
Workbook wb(srcReadWriteTabDelimited); | |
//Access first worksheet | |
Worksheet ws = wb.GetWorksheets().Get(0); | |
//Access cell A1 | |
Cell cell = ws.GetCells().Get(u"A1"); | |
//Get the string value of cell A1 | |
U16String strVal = cell.GetStringValue(); | |
//Print the string value of cell A1 | |
U16String cellValue(u"Cell Value: "); | |
std::cout << cellValue.ToUtf8() << strVal.ToUtf8() << std::endl; | |
//Access cell C4 | |
cell = ws.GetCells().Get(u"C4"); | |
//Put the string value of cell A1 into C4 | |
U16String strValPtr(strVal); | |
cell.PutValue(strValPtr); | |
//Save the workbook in tab delimited format | |
wb.Save(outReadWriteTabDelimited, SaveFormat::TabDelimited); | |
Aspose::Cells::Cleanup(); |