public override Task <bool> Export(Stream stream, DataLogReport dlr) { return(Task.Factory.StartNew(() => { try { // TODO [email protected]: Not necessary var scaleReduction = 60; // TODO DEFINE var file = new XlsFile((showAllData ? 2 : 1) + dlr.graphImages.Count, TExcelFileFormat.v2013, true); file.AllowOverwritingFiles = true; file.PrintScale = scaleReduction; // Note: [email protected]: Per kyle's original writing // SET A UNIFORM CELL WIDTH FOR COVER PAGE ITEMS. DEFAULT COLUMN WIDTH = 3189 AND SETTING IT TO 1.3x RESULTING IN 4317 file.SetColWidth(1, 8, 4317); // TODO DEFINE InitializeToFile(file); RenderFile(file, dlr); // Commit file to stream using (var pdf = new FlexCelPdfExport(file, true)) { pdf.GetFontData += (sender, e) => { var ms = new MemoryStream(1024 * 64); using (var fontStream = dlr.localization.GetFontStream()) { var buffer = new byte[1024]; var read = -1; while ((read = fontStream.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, buffer.Length); } } e.FontData = ms.ToArray(); ms.Dispose(); }; pdf.BeginExport(stream); for (int i = 1; i <= file.SheetCount; i++) { file.ActiveSheet = i; pdf.ExportSheet(); } pdf.EndExport(); } return true; } catch (Exception e) { Log.E(this, "Failed to export datalog report", e); return false; } })); }