new v6.2 release for GrapeCity Documents for Excel (GcExcel), our high-speed API library for creating Excel spreadsheets. This new release includes updates to the existing GcExcel .NET and Java libraries and API tools and additions to our JavaScript-based GrapeCity Documents Data Viewer. Have a look at the details of the release below.
With the v6.2 release, GcExcel adds support for SpreadJS file format ‘.sjs’ in its Java edition. The format helps to import/export spreadsheet features from SpreadJS ‘.sjs’ files to Excel or export of large files of popular formats such as xlsx, xlsm, csv, ssjson, etc., to ‘.sjs’ in lesser time and smaller in size.
The existing methods of GcExcel Java - open and save of the Workbook class have been enhanced to support .sjs files. While loading or saving a ‘.sjs’ file, you can use the new enum option “Sjs” in OpenFileFormat and SaveFileFormat enums.
Download GrapeCity Documents for Excel .NET and Java now!
With the support of the new file format, the following features will be supported -
New classes SjsOpenOptions and SjsSaveOptions, have also been added, using which you can control which spreadsheet features to include/exclude while importing/exporting the ‘.sjs’ files.
The following code loads the SpreadJS .sjs file, turns off Formulas and Styles using SjsOpenOptions, and opens/saves the file using GcExcel:
// Create a new workbook
Workbook workbook = new Workbook();
InputStream stream = this.getResourceStream("sjs\\LoanDetails.sjs");
// OpenOptions for .sjs file format
SjsOpenOptions openOptions = new SjsOpenOptions();
openOptions.setIncludeFormulas(false);
openOptions.setIncludeStyles(false);
// GcExcel support using OpenOptions to open .sjs file format.
workbook.open(stream, openOptions);
// Save to a .sjs file
workbook.save("OpenSjsWithOpenOptions.sjs");
Have a look at the following resources to learn more about this format.
GcExcel now also supports SpreadJS styles in importing and exporting .sjs files. The following new properties will be supported:
At times it is possible to print a workbook with long worksheets sheets to be printed on both sides of a page. GcExcel .NET supports the Duplex enum in PrintOutOptions class to enable/disable double-sided printing on a page. There are four options in the enum that the user can use accordingly to print the workbook:
The following code prints three copies of the workbook with double-sided vertical printing:
// Create a print options.
PrintOutOptions options = new PrintOutOptions();
// Set the printer name to print.
options.ActivePrinter = "[Real printer name]";
// Print 3 copies.
options.Copies = 3;
//Set Double-sided, vertical printing.
options.Duplex = System.Drawing.Printing.Duplex.Vertical;
//Print this workbook to "Microsoft Print to PDF".
workbook.PrintOut(options);
GcExcel adds new TextAlignment property in the ITextRange interface that gets or sets the alignment of a text range or paragraph in a shape. This property sets the text alignment to left, right, center, distribute, and justify. This is helpful in scenarios where you have to align text for professional reports per UI design rules or align text per data formats, like text to left or numbers to right.
The following code sets the alignment of multiple paragraphs in a shape to Center and Left:
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.RoundedRectangle, (double)10, (double)10, (double)320, (double)150);
shape.TextFrame.TextRange.TextAlignment = TextAlignmentAnchor.Left;
shape.TextFrame.TextRange.Font.Name = "Calibri";
shape.TextFrame.TextRange.Font.Size = 16;
shape.TextFrame.TextRange.Font.Color.RGB = Color.Black;
shape.TextFrame.TextRange.Font.Underline = TextUnderlineType.None;
shape.TextFrame.TextRange.Paragraphs.Add("Quarterly Results");
shape.TextFrame.TextRange.Paragraphs[0].TextAlignment = TextAlignmentAnchor.Center;
shape.TextFrame.TextRange.Paragraphs[0].Font.Size = 28;
shape.TextFrame.TextRange.Paragraphs[0].Font.Underline = TextUnderlineType.Single;
shape.TextFrame.TextRange.Paragraphs.Add("");
shape.TextFrame.TextRange.Paragraphs.Add("Business Domain: E-Commerce");
shape.TextFrame.TextRange.Paragraphs[2].TextAlignment = TextAlignmentAnchor.Left;
shape.TextFrame.TextRange.Paragraphs.Add("Quarter: Q4");
shape.TextFrame.TextRange.Paragraphs[3].TextAlignment = TextAlignmentAnchor.Left;
In certain documents, it is desired to set the text orientation in the vertical direction. GcExcel adds the Direction property to API of shape and chart:
The Direction property accepts the TextDirection enum option that helps to set the orientation of text in the following directions:
The following code sets the TextDirection of JP text to a Stacked direction:
var shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, worksheet.Range["C2:F12"]);
shape.TextFrame.TextRange.Add("グレープシティへようこそ");
//Set the text direction to be stacked, and the text reading order from right to left.
shape.TextFrame.Direction = TextDirection.Stacked;
In the last release, GcExcel .NET added support for the import and export of SpreadJS .sjs files, and with the v6.2 release, we now extend this support to GcDataViewer. You can open the SpreadJS .sjs files through the UI of the viewer or client-side code.
In the ‘Select Data file’ (Open) dialog of the viewer, Data Type now accepts the SJS file type. The file Source can be Local or Remote.
The ‘openFile’ method has been updated to accept FileType.SJS enum value in the second parameter, as well as new ‘SjsOpenOptions’ in the openOptions (third) parameter. The new SjsOpenOptions have been added to the client-side API, which helps to provide certain SpreadJS features to load while opening the .sjs file. The following client-side code opens a .sjs file:
var viewer;
var sjs_OpenOptions = {
showHiddenSheets: true,
showHiddenRows: false,
showHiddenColumns: true,
keepRowGroups: false,
};
function loadFile(fileUrl) {
fetch(fileUrl).then(response => {
response.blob().then(res => {
viewer.openFile(res, FileType.SJS, sjs_OpenOptions);
});
})
}
window.onload = function () {
viewer = new GcDataViewer("#viewer");
loadFile("/Files/12-month cash flow statement.sjs");
}
GcDataViewer supports several keyboard shortcuts, which can make working with the viewer and cell operations more efficient. Please refer to the list of Keyboard shortcuts supported in the Help link below.
GcDataViewer now supports numerical count aggregation in the status bar. When a file is loaded, and cells are selected, GcDataViewer will show the count of cells having numerical data. The following snapshot shows a cell range selected where three cells have numerical data: