Fixed Columns Width Text
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 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);
}
}
Want more?
Like it?
Published: December 13, 2018 | Modified: September 9, 2019 | Author: Marek Turis