protected virtual void DoGetSpreadTable(SpreadsheetWithCopyToBookOptions options, string tableName, out DataTable result)
        {
            var spread = options?.Spreadsheet?.Workbook ?? Workbook;

            var range = SpreadsheetUtils.GetWorkbookRange(spread, tableName);

            result = SpreadsheetUtils.GetDataTable(range);

            CopyRangeToBook(range, options);
            AddComments(range, options.Comment);
        }
        protected void DoCreateDataTable(out DataTable dataTable)
        {
            var workbook = GetCmdletSpreadsheet();

            var range = SpreadsheetUtils.GetWorkbookRange(workbook, TableName);

            dataTable = SpreadsheetUtils.GetDataTable(range);

            CopyRangeToBook(range);
            AddComments(range);
        }
        protected virtual string GenerateTableHtml(SpreadTableOptions options)
        {
            string    htmlTable;
            IWorkbook workbook        = null;
            bool      disposeWorkbook = false;

            try
            {
                if (options._Spreadsheet != null)
                {
                    workbook = options._Spreadsheet.Workbook;
                }
                else if (!string.IsNullOrWhiteSpace(options._FileName))
                {
                    disposeWorkbook = true;

                    string fileName = Project.Current.MapPath(options._FileName);
                    if (!File.Exists(fileName))
                    {
                        throw new Exception($"File '{fileName}' does not exist.");
                    }

                    workbook = SpreadsheetUtils.CreateWorkbook();
                    workbook.LoadDocument(fileName);
                }
                else
                {
                    workbook = Host?.Spreadsheet?.Workbook;
                }

                if (workbook == null)
                {
                    throw new Exception("Spreadsheet is not specified");
                }

                var range = SpreadsheetUtils.GetWorkbookRange(workbook, options._TableName);

                var optionsHtml = new DevExpress.XtraSpreadsheet.Export.HtmlDocumentExporterOptions()
                {
                    SheetIndex = workbook.Sheets.IndexOf(range.Worksheet),
                    Range      = range.GetReferenceA1(),
                    Encoding   = Encoding.Unicode
                };

                using var stream = new MemoryStream();
                workbook.ExportToHtml(stream, optionsHtml);
                stream.Seek(0, SeekOrigin.Begin);

                using var reader = new StreamReader(stream, Encoding.UTF8);
                htmlTable        = reader.ReadToEnd();
            }
            finally
            {
                if (disposeWorkbook)
                {
                    workbook?.Dispose();
                }
            }

            return(htmlTable);
        }