可以将spread保存成pdf,然后加载这个pdf预览。
下面是保存pdf的参考代码,您可以不下载这个pdf保存在内存或者临时路径
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.Filter = "PDF File (.pdf)|*.pdf";
- bool? useClick = saveFileDialog.ShowDialog();
- if (useClick == true)
- {
- var stream = saveFileDialog.OpenFile();
- gcSpreadSheet1.Workbook.Name = "WorkBook";
- gcSpreadSheet1.Sheets[0].Name = "Sheet 0";
- GrapeCity.Windows.SpreadSheet.Data.PrintInfo printtest;
- printtest = gcSpreadSheet1.Sheets[0].PrintInfo;
- printtest.FooterCenter = "This is Page &P";
- printtest.HeaderCenter = "&A of &F";
- printtest.HeaderLeft = "&KFFFF00Color &KFF0000RedColor";
- printtest.BestFitColumns = true;
- printtest.UseMax = true;
- GrapeCity.Windows.SpreadSheet.Data.PdfExportSettings test;
- test = new GrapeCity.Windows.SpreadSheet.Data.PdfExportSettings();
- test.Title = "Print PDF";
- test.Author = "GrapeCity, Inc.";
- test.DisplayDocTitle = true;
- test.FitWindow = true;
- gcSpreadSheet1.SavePdf(stream, test, 0);
- stream.Dispose();
- }
复制代码 |