1、
//初始化spread
private void initSpread()
{
InputMap im;
im = Report_fpSpread.GetInputMap(InputMapMode.WhenFocused);
im.Put(new Keystroke(Keys.C, Keys.None), SpreadActions.ClipboardCopy);
im.Put(new Keystroke(Keys.V, Keys.None), SpreadActions.ClipboardPasteAll);
}
2、
//打开spread文件
private void openExcel(string filename)
{
filename = System.AppDomain.CurrentDomain.BaseDirectory + "//" + filename;
this.Report_fpSpread.Open(filename);
}
3、
this.Report_fpSpread.Sheets[sheetIndex].RemoveRows(rowindex,rowsCount);
this.Report_fpSpread.Sheets[sheetIndex].Rows.Add(rowindex, rowsCount);
this.Report_fpSpread.Sheets[sheetIndex].Cells[rowindex, cloumnIndex].Value =val;
4、自动换行
FarPoint.Win.Spread.CellType.TextCellType.WordWrap = true
5、输出excel
this.Report_fpSpread.SaveExcel(filePath);
6、打印设置
FarPoint.Win.Spread.PrintInfo printset = new FarPoint.Win.Spread.PrintInfo();
FarPoint.Win.Spread.PrintMargin printmar = new FarPoint.Win.Spread.PrintMargin();
printmar.Left = 80;
printmar.Right = 0;
printmar.Top = 20;
printmar.Bottom = 20;
printset.Centering = FarPoint.Win.Spread.Centering.None;
printset.FirstPageNumber = 1;
printset.Margin = printmar;
printset.Opacity = 60;
printset.Orientation = FarPoint.Win.Spread.PrintOrientation.Landscape;
printset.ShowBorder = false;
printset.ShowColor = false;
printset.ShowColumnHeader = FarPoint.Win.Spread.PrintHeader.Hide;
printset.ShowRowHeader = FarPoint.Win.Spread.PrintHeader.Hide;
printset.ShowGrid = false;
printset.ShowShadows = false;
printset.ZoomFactor = 0;
this.Report_fpSpread.Sheets[sheetIndex].PrintInfo = printset;