您好,
这个问题可以使用以下代码进行尝试
- private void detail_BeforePrint(object sender, EventArgs e)
- {
- Image img = new Bitmap(100, 15);
- Graphics g = Graphics.FromImage(img);
- g.DrawLine(new Pen(new SolidBrush(Color.Black)), 0, 0, 100, 15);
- g.DrawLine(new Pen(new SolidBrush(Color.Black)), 0, 15, 100, 0);
- picture1.Image = img;
- }
复制代码
XAML后台代码中的导出也可以直接使用Viewer自带的Export方法,如下:
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
-
- try
- {
- dlgSave.Filter = "*.xlsx|.xlsx";
- dlgSave.FileName = "";
- if (dlgSave.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- System.Windows.Forms.Application.DoEvents();
- GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
- XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
- //XlsExport1.Export(report.Document, dlgSave.FileName);
- MyView.Export(XlsExport1, new System.IO.FileInfo(dlgSave.FileName));
- System.Windows.MessageBox.Show("文件已经成功导出!");
- }
- }
- catch (Exception)
- {
- System.Windows.MessageBox.Show("导出文件错误请检查相关设置!");
- }
- finally
- {
- System.Windows.Forms.Application.DoEvents();
- }
- }
复制代码 |