Fixed Columns Width Text
GemBox.Spreadsheet for Java has been retired
Following example shows how to read and write Fixed Columns Width Text file which is text file with each column size fixed to some arbitrary number of characters.

import com.gembox.spreadsheet.*;
class Program {
public static void main(String[] args) throws java.io.IOException {
// If using the Professional version, put your serial key below.
SpreadsheetInfo.setLicense("FREE-LIMITED-KEY");
// Define columns width (for input file format)
FixedWidthLoadOptions loadOptions = new FixedWidthLoadOptions(
new FixedWidthColumn(8),
new FixedWidthColumn(8),
new FixedWidthColumn(8));
// Load file
ExcelFile workbook = ExcelFile.load("%#FixedColumnsWidthText.prn%", loadOptions);
// Modify file
workbook.getWorksheets().getActiveWorksheet().getUsedCellRange(true).sort(false).by(1).apply();
// Define columns width (for output file format)
FixedWidthSaveOptions saveOptions = new FixedWidthSaveOptions(
new FixedWidthColumn(8),
new FixedWidthColumn(8),
new FixedWidthColumn(8));
workbook.save("SortedFixedColumnsWidthText.prn", saveOptions);
}
}
See also
Next steps
Published: December 13, 2018 | Modified: December 19, 2022 | Author: Marek Turis