I have looked all over and can’t seem to locate any info, probably not searching correctly, on how to print a tableview’s data out in a table format with header rows. Any assistance would be greatly appreciated.
Thanks!
I have looked all over and can’t seem to locate any info, probably not searching correctly, on how to print a tableview’s data out in a table format with header rows. Any assistance would be greatly appreciated.
Thanks!
bumping my own thread…anyone have a solution, or even a reference that I am unaware of that I can go read my self?
Thanks!
Tables have a print: action method. Make a button, control-click-drag from the button to the table, and click in the circle next to print: in the dialog.
Shane,
Thanks, but I think that doesn’t inlcude the header row when printing, at least I haven’t found a way to get it to. Also, do you know of a way to get all the columns to fit on the page? I have 7 columns that I need to fit.
Iappreciate the help
It should give the header row OK, but if you want to paginate, you have to do that yourself. I’ve never tried it so I don’t know what’s involved: looks like you need to consult “Printing Programming Topics for Cocoa” in Xcode Help.
Thanks for the assistance and the point to documentation. I am still learning all this.
Cheers,
Mark
Hi Mark,
here is a workaround for printing a table:
Put a box from IB under the table view. So you will not print the table itself but the contents of the box (i.e. the table)
Write the script:
property theView : missing value
-- IB Actions (button clicks)
on thePrint_(sender)
doPrinting()
end thePrint_
Bind the box to the variable theView – for example
Bind the print button to the action handler thePrint_(sender) – for example
Use the following code; test some parameters.
on doPrinting()
set mySharedPrintInfo to current application's NSPrintInfo's sharedPrintInfo()
mySharedPrintInfo's setLeftMargin_(20.0)
mySharedPrintInfo's setRightMargin_(0.0)
mySharedPrintInfo's setTopMargin_(20.0)
mySharedPrintInfo's setBottomMargin_(10.0)
mySharedPrintInfo's setOrientation_(0)
mySharedPrintInfo's setHorizontalPagination_(1)
mySharedPrintInfo's setVerticalPagination_(0)
mySharedPrintInfo's setVerticallyCentered_(0)
mySharedPrintInfo's setHorizontallyCentered_(1)
set thePrintOp to current application's NSPrintOperation's printOperationWithView_printInfo_(theView, mySharedPrintInfo)
thePrintOp's runOperation
end doPrinting
Greetings
Heiner
Model: iMac
Browser: Safari 525.13
Operating System: Mac OS X (10.6)
Thanks Heiner! I will give that a try.
Much appreciated,
Mark