-
Notifications
You must be signed in to change notification settings - Fork 4
/
ExportActions.cs
47 lines (39 loc) · 1.68 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
using DevExpress.Spreadsheet;
using DevExpress.XtraSpreadsheet.Export;
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace SpreadsheetControl_API
{
class ExportActions
{
#region Actions
public static Action<IWorkbook> ExportToHTMLAction = ExportToHTMLValue;
#endregion
private static void ExportToHTMLValue(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);
htmlStream.Close();
#endregion #ExportToHTML
System.Diagnostics.Process.Start("OutputRange.html");
System.Diagnostics.Process.Start("OutputWorksheet.html");
}
}
}