您好,
这个问题因为framework的多线程机制导致的。我发现网上有很多的问题,大部分是出现这种情况分为两种。第一种应该是界面还来不及响应Invoke,第二种是界面线程已经结束。
您可以参考以下代码,看是否能够解决您的问题。
- FarPoint.Win.Spread.FpSpread fpSpread1 = new FarPoint.Win.Spread.FpSpread();
- fpSpread1.OpenExcel("test.xlsx");
- fpSpread1.Location = new Point(10, 10);
- fpSpread1.Height = 200;
- fpSpread1.Width = 400;
- Controls.Add(fpSpread1);
- fpSpread1.ActiveSheet.ColumnCount = 4;
- fpSpread1.ActiveSheet.RowCount = 4;
- FarPoint.Win.Spread.PrintInfo printset = new FarPoint.Win.Spread.PrintInfo();
- printset.PrintToPdf = true;
- printset.PdfFileName = "results.pdf";
- // Assign the printer settings and print
- fpSpread1.Sheets[0].PrintInfo = printset;
- fpSpread1.PrintSheet(0);
复制代码
希望能够帮助到您。 |