本文整理汇总了C#中GridView.ExportToHtml方法的典型用法代码示例。如果您正苦于以下问题:C# GridView.ExportToHtml方法的具体用法?C# GridView.ExportToHtml怎么用?C# GridView.ExportToHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridView
的用法示例。
在下文中一共展示了GridView.ExportToHtml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: exportFile
//.........这里部分代码省略.........
if (link != null)
link.PrintingSystem.ExportToXlsx(f.FileName, new XlsxExportOptions(((PLGridView)gridView)._TextExportMode));
else
gridView.ExportToXlsx(f.FileName, new XlsxExportOptions(((PLGridView)gridView)._TextExportMode));
}
else
{
if (link != null)
link.PrintingSystem.ExportToXlsx(f.FileName, new XlsxExportOptions(TextExportMode.Text));
else
gridView.ExportToXlsx(f.FileName, new XlsxExportOptions(TextExportMode.Text));
}
succ = true;
}
else if (ext.Equals("pdf"))
{
if (link != null)
link.PrintingSystem.ExportToPdf(f.FileName);
else
gridView.ExportToPdf(f.FileName);
succ = true;
}
else if (ext.Equals("rtf"))
{
if (link != null)
link.PrintingSystem.ExportToRtf(f.FileName);
else
gridView.ExportToRtf(f.FileName);
succ = true;
}
else if (ext.Equals("htm"))
{
if (link != null)
link.PrintingSystem.ExportToHtml(f.FileName);
else
gridView.ExportToHtml(f.FileName);
succ = true;
}
}
}
catch (Exception ex)
{
PLException.AddException(ex);
return false;
}
finally
{
if (FrameworkParams.wait != null && flag == true)
FrameworkParams.wait.Finish();
if (succ == true)
{
outFileName = filePath;
if (ext.Equals("xls") || ext.Equals("xlsx"))
{
try
{
System.Globalization.CultureInfo oldCi = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
Microsoft.Office.Interop.Excel.ApplicationClass excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(filePath,
0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
Microsoft.Office.Interop.Excel.Worksheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelWorkbook.ActiveSheet;
excelSheet.Columns.AutoFit();
excelWorkbook.Save();
示例2: ExportData
public static void ExportData(DataTable _dt, GridView _grid)
{
if (_dt != null && _dt.Rows.Count > 0)
{
SaveFileDialog sDialog = new SaveFileDialog();
sDialog.Filter = "Microsoft Excel (*.xls)|*.xls|Microsoft Excel 2007 (*.xlsx)|*.xlsx|PDF (*.pdf)|*.pdf|Rich Text Format (*.rtf)|*.rtf|Webpage (*.html)|*.html|Rich Text File (*.rtf)|*.rtf|Text File (*.txt)|*.txt";
sDialog.Title = Lang.GetMessageByLanguage("000007", Culture, ResourceMessage);
if (sDialog.ShowDialog() == DialogResult.OK)
{
switch (sDialog.FilterIndex)
{
case 1:
_grid.ExportToXls(sDialog.FileName);
break;
case 2:
_grid.ExportToXlsx(sDialog.FileName);
break;
case 3:
_grid.ExportToPdf(sDialog.FileName);
break;
case 4:
_grid.ExportToText(sDialog.FileName);
break;
case 5:
_grid.ExportToHtml(sDialog.FileName);
break;
case 6:
_grid.ExportToRtf(sDialog.FileName);
break;
case 7:
_grid.ExportToText(sDialog.FileName);
break;
}
if (XtraMessageBox.Show(Lang.GetMessageByLanguage("000006", Culture, ResourceMessage).Replace("$FileName$", sDialog.FileName), (User.UserInfo.LanguageID.Equals("VN")) ? "Thông Báo" : "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
Process.Start(sDialog.FileName);
}
}
}
else
{
return;
}
}