This ';gridview'; is a control in Visual Studio. I've already succeeded in creating the ';Excel Export'; from a gridview, but now when the user clicks the ';Export'; button, the worksheet already needs to be ready to print with no adjustments -- this is the part I can find no answer to.How can l control the Excel Export from a Gridview. I want to be able to control page size, font, orientation?
I have created Macros before that basically re-formats whole workbooks (from 3 to 50 worksheets) for printing. It is easier to control from within the VBA code of MS-Excel. And it will allow one to make any changes they so desire, including popup dialog to ask the User for possible Headings, Sizes, Colors, and other issues that one might wish to make more flexible.
I would paste an example of such, but it is about 300 lines of code, so I will put just a few specific lines here:
Selection.SpecialCells( xlCellTypeLastCell ).Select
Selection.Activate
intRow1 = ActiveCell.Row + 2
intCtr2 = intCtr2 + 1
If intCtr2 = 3 Then
Cells(intRow1, 1).Activate
ActiveWindow. SelectedSheets. HPageBreaks. Add Before:=ActiveCell
intCtr2 = 0
End If
Sheets(1).Activate
With ActiveSheet.PageSetup
.PrintTitleRows = ';';
.PrintTitleColumns = ';';
.PrintArea = ';';
.LeftHeader = ';';
.CenterHeader = ';%26amp;';';Arial,Bold';';%26amp;14'; %26amp; strTitle1 %26amp; vbLf %26amp; _
';%26amp;';';Arial,Regular';';%26amp;10'; %26amp; ';%26amp;A -- '; %26amp; strTitle2 %26amp; '; Responses';
.RightHeader = ';';
.LeftFooter = ';%26amp;D -- %26amp;T';
.CenterFooter = ';';
.RightFooter = ';Page %26amp;P of %26amp;N';
.HeaderMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.25)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
' .PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
With ActiveWindow
.View = xlPageBreakPreview
.Zoom = 90
.SelectedSheets.PrintPreview
End With
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment