さまざまな印刷オプションを設定する次のコードがあります。
private void ConfigureByCustomerForPrinting()
{
_xlSheet.PageSetup.PrintArea = "A1:" +
GetExcelTextColumnName(
_xlSheet.UsedRange.Columns.Count) +
_xlSheet.UsedRange.Rows.Count;
_xlSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape;
_xlSheet.PageSetup.FitToPagesWide = 1;
_xlSheet.PageSetup.FitToPagesTall = 100;
_xlSheet.PageSetup.Zoom = false;
_xlSheet.PageSetup.LeftMargin = _xlApp.Application.InchesToPoints(0.5);
_xlSheet.PageSetup.RightMargin = _xlApp.Application.InchesToPoints(0.5);
_xlSheet.PageSetup.TopMargin = _xlApp.Application.InchesToPoints(0.5);
_xlSheet.PageSetup.BottomMargin = _xlApp.Application.InchesToPoints(0.5);
_xlSheet.PageSetup.HeaderMargin = _xlApp.Application.InchesToPoints(0.5);
_xlSheet.PageSetup.FooterMargin = _xlApp.Application.InchesToPoints(0.5);
}
シートが生成されると、横方向の値が尊重されますが、以下に示すように:
...幅 (幅) と高さ (高さ) がそれぞれ 1 と 100 に設定されていますが、これはラジオ ボタンが選択されていません。代わりに、「通常のサイズに調整 - %」が設定され、選択されます。なんで?おそらくこれで問題ないと思いますが、ユーザーは 1 と 100 に設定することを望んでいます。