1
私のプログラムは同じEXCEL
ファイルにWorkSheets
を書き出します。そして、印刷のデフォルト設定を "Print Entire Workbook"に設定しようとしています。 PrintOutEx
を使用して設定しようとしますが、すぐにworksheets
が印刷されるか、EXCEL
をエクスポートするとプレビューモードになります。EXCEL印刷設定「印刷ワークシート全体」の設定方法は? C#
デフォルトをPrint Entire Workbook
に設定したいだけです。私は最初にユーザーにExcelファイルを読ませたいと思っています。どのようにそれを行うことができますか?ありがとう。 C#を使用してブック全体を印刷する
Excel.Application oApp;
Excel.Worksheet oSheet;
Excel.Workbook oBook;
//Check if the row records are more then the table row.
if (rowCount > 19)
more_than_table = true;
oApp = new Excel.Application();
oBook = oApp.Workbooks.Add();
do {
Debug.WriteLine("Page: " + sheet_page);
oSheet = (Excel.Worksheet)oBook.Worksheets.Add(After: oBook.Sheets[oBook.Sheets.Count]);
oSheet.Name = invoices_tb.Text + "(" + sheet_page + ")";
oApp.Application.UserName = invoices_tb.Text;
oApp.Visible = true;
//Set up the excel page style, orientation and the center alignment
//oSheet.PageSetup.Zoom = false;
oSheet.PageSetup.Zoom = false;
oSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape;
oSheet.PageSetup.CenterHorizontally = true;
oSheet.PageSetup.FitToPagesWide = 1;
//Set the page number
oSheet.PageSetup.CenterFooter = "Page &P of &N";
//**
//Many code for set up excel and value
//**
double how_many_page = Convert.ToDouble(rowCount)/19.0f ;
Debug.WriteLine("many page: " + how_many_page);
if (how_many_page > sheet_page)
sheet_page++;
else
more_than_table = false;
} while (more_than_table);
//Set to preview the page when file export.
oBook.PrintOutEx(1, sheet_page, 1, true, Type.Missing, true, false, Type.Missing);
}
catch (Exception ex)
{
MessageBox.Show("Excel Closed.");
}