Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include formatting information in windows clipboard copy buffer for pasting into Excel

My application writes tabular data to the windows copy buffer for the user to paste into Excel. This works fine for unformatted tabular data including tab-stops and new lines for cell and row delimeters.

I'd like to include formatting data in the copy buffer: grid lines, background colors, etc. Can I do this, and if so, where can I find a specification for encoding the formatting data?

like image 583
pancake Avatar asked Jun 09 '11 21:06

pancake


1 Answers

Yes, it's possible (obviously, you can copy formatted Excel data from one running instance of Excel to another via the clipboard, so it must be possible!)

Remember that the Windows clipboard can hold things in more than one format at the same time. The format you want for Excel formatted grid stuff is called BIFF, that is, The Binary Interchange File Format. It's the same format as Excel actually stores files in. A reasonable source of BIFF documentation is available from Open Office.

Once you figure out the basics of BIFF, you'll find that the easiest way to generate the BIFF you want is to copy a model of the cells you want from an Excel spreadsheet and examine what's in the clipboard.

like image 69
Joel Spolsky Avatar answered Sep 19 '22 18:09

Joel Spolsky