c#打印時頁面設置
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application tmpExcel = new Excel.ApplicationClass();
Excel.Workbook tmpbook = tmpExcel.Workbooks.Open(tmppath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); //表格的權限設定,如只讀,密碼,權限
//以下是添加新的sheet
Excel.Worksheet objsheet = (Excel.Worksheet)tmpbook.Worksheets.Add(Type.Missing, Type.Missing, Type.Missing);
objsheet.PageSetup.Orientation = XlPageOrientation.xlLandscape;//頁面方向橫向
objsheet.PageSetup.Zoom = false; //打印時頁面設置,必須設置為false,下面的二行頁高,頁寬才有效
objsheet.PageSetup.FitToPagesTall = 1; //頁高
objsheet.PageSetup.FitToPagesWide = 1; //頁寬
objsheet.PageSetup.Zoom = 75;//打印時頁面設置,縮放比例
objsheet.PageSetup.TopMargin = 0; //上邊距為0
objsheet.PageSetup.BottomMargin = 0; //下邊距為0
objsheet.PageSetup.LeftMargin = 0; //左邊距為0
objsheet.PageSetup.RightMargin = 0; //右邊距為0
objsheet.PageSetup.CenterHorizontally = true;//水平居中
摘自 brian0031的專欄