回复 4楼yingjunn的帖子
yingjunn 你好
在进行 PDF 导出时,中文字体需要使用 SimSun 字体,不然就会出现乱码
如果你的环境中缺少 SimSun 字体可以从这个下载:PDF中文字体
- public partial class MainPage : UserControl
- {
- public MainPage()
- {
- InitializeComponent();
- gcSpreadSheet1.ActiveSheet.DefaultStyle.FontFamily = new System.Windows.Media.FontFamily("SimSun");
- gcSpreadSheet1.ActiveSheet.Cells[0, 0].Value = "我要导出中文";
- gcSpreadSheet1.ActiveSheet.Cells[1, 0].Value = "我要导出中文";
- gcSpreadSheet1.ActiveSheet.Cells[2, 0].Value = "我要导出中文";
- gcSpreadSheet1.ActiveSheet.Cells[3, 0].Value = "我要导出中文";
- gcSpreadSheet1.ActiveSheet.Cells[4, 0].Value = "我要导出中文";
- }
- private void button1_Click(object sender, RoutedEventArgs e)
- {
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.Filter = "PDF File (.pdf)|*.pdf";
- bool? useClick = saveFileDialog.ShowDialog();
- if (useClick == true)
- {
- var stream = saveFileDialog.OpenFile();
- 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, 0);
- stream.Dispose();
- }
- }
- }
复制代码 |