-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExportActions.cs
48 lines (40 loc) · 1.71 KB
/
ExportActions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using DevExpress.Spreadsheet;
using DevExpress.XtraSpreadsheet.Export;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpreadsheetControl_WPF_API_Part02
{
class ExportActions
{
#region Actions
public static Action<IWorkbook> ExportToHTMLAction = ExportToHTML;
#endregion
private static void ExportToHTML(IWorkbook workbook)
{
#region #ExportToHTML
workbook.LoadDocument("Documents\\ExpenseReport.xlsx");
workbook.Calculate();
Worksheet worksheet = workbook.Worksheets[0];
// Create an object containing HTML export options.
HtmlDocumentExporterOptions options = new HtmlDocumentExporterOptions();
// Set HTML-specific export options.
options.CssPropertiesExportType = DevExpress.XtraSpreadsheet.Export.Html.CssPropertiesExportType.Style;
options.Encoding = Encoding.UTF8;
// Specify the part of the document to be exported to HTML.
options.SheetIndex = worksheet.Index;
options.Range = "B11:O28";
// Export a document to an HTML file with the specified options.
workbook.ExportToHtml("OutputRange.html", options);
// Export the entire worksheet to a stream as HTML.
FileStream htmlStream = new FileStream("OutputWorksheet.html", FileMode.Create);
workbook.ExportToHtml(htmlStream, worksheet.Index);
#endregion #ExportToHTML
System.Diagnostics.Process.Start("OutputRange.html");
System.Diagnostics.Process.Start("OutputWorksheet.html");
}
}
}