You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Reogrid doesn't seem to load print settings saved in an .xlsx file at this time. I've got spreadsheets I want to print off, and use the print settings embedded into the spreadsheet to do the printing
instead of having the user having to reset them to match what was already there.
I'm currently working a print preview dialog with comboboxes to adjust the settings and view the adjustments in real time... however, its still not ready.. lots of fun,
almost nobody has documentation on the printpreviewcontrol (not the dialog, just the control) making it harder to figure out.
Anyhow, I'd really like to be able to open a spreadsheet, goto print,and have it load the settings from the file and prepopulate the PageSettings for the Current Worksheet or sheets...
For anyone curious on using the print preview control to create your own dialog
1) you must create a print session from the reogridcontrol, as documented in the examples
private void frmCustomPrintDlg_Load(object sender, EventArgs e)
{
if (PrintSettings.Landscape)
pageOrientationComboBoxExt1.SelectedIndex = 0;
else
pageOrientationComboBoxExt1.SelectedIndex = 1;
// created a session object to hold the session for the duration
_session = _rgc.CurrentWorksheet.CreatePrintSession();
ppc.Document = _session.PrintDocument;
} // end of frmCustomPrintDlg_Load()
2).Then as you manipulate or change settings, update the PrintSettings for the CurrentWorksheet of the reogridcontrol
and invalidate the preview
For example changing from portrait or landscape to landscape or portrait orientation
private void pageOrientationComboBoxExt1_SelectedIndexChanged(object sender, EventArgs e)
{
if (pageOrientationComboBoxExt1.SelectedIndex == 0)
{
pagesCollatedComboBoxExt1.LandscapeOrientation = true; // update combobox image
pageMarginsComboBoxExt1.LandscapeOrientation = true; // update combobox image
pageScalingComboBoxExt1.LandscapeOrientation = true; // update combobox image
_rgc.CurrentWorksheet.PrintSettings.Landscape = true; // update printsettings
}
else
{
pagesCollatedComboBoxExt1.LandscapeOrientation = false; // update combobox image
pageMarginsComboBoxExt1.LandscapeOrientation = false; //
pageScalingComboBoxExt1.LandscapeOrientation = false; //
_rgc.CurrentWorksheet.PrintSettings.Landscape = false; // update printsettings
}
ppc.InvalidatePreview(); // redraw our print preview in the control after the change
} // end of pageOrientationComboBoxExt1_SelectedIndexChanged
or changing page margins
private void pageMarginsComboBoxExt1_SelectedIndexChanged(object sender, EventArgs e)
{
PageMarginsItem pmi = (PageMarginsItem)pageMarginsComboBoxExt1.Items[pageMarginsComboBoxExt1.SelectedIndex];
PageMargins pm = new PageMargins(pmi.TopMargin, pmi.BottomMargin, pmi.LeftMargin, pmi.RightMargin);
_rgc.CurrentWorksheet.PrintSettings.Margins = pm;
ppc.InvalidatePreview();
}
3) Don't forget to Dispose of the session object when done!
If someone is willing to get the page settings from the xlsx working and share it, I'm willing to post the full working Print Preview Dialog and Page Setup dialog when I finish them.
Offline
Nice, thanks! It would be better to make ReoGrid can load print settings from Excel file.
Offline