Copying Spreadsheet to PowerPoint?

Hi Adrian,


I'd like to be able to copy a FlexCel worksheet directly into PowerPoint using the clipboard. I have the code to copy in the Biff8 format but PowerPoint doesn't seem to recognize it. Instead all I get is the plain text, not the nicely formatted output.

Is it possible to copy directly from Flexcel to PowerPoint? Or is this not supported?

Thanks,

Steve

Copying directly to powerpoint is not supported, but I have been actually experimenting with copying as html, and it works quite well, at least in word that is where I have been testing it. 


 Images are not supported, even if you embed them as html5. Excel itself does copy the images in html and the other office tools understand it, but it uses some proprietary extensions I'd rather not use.

I expect the next version of FlexCel will have the support to copy to html directly, but I didn't got the time to put it and test it for 6.7.1 (As it is usual with FlexCel, 6.7.1 is actually a big release despite the small increment in the version number, and it took a lot of effort to complete)

To copy to html isn't complex, you just need to run FlexCelHtmlExport to a TStringStream, then copy it in "clipboard html" (which is different than just copying it as is, but not too much complex).

I was going to paste the code I have here to test the feature, but then I realized it is in .NET, as I hadn't time to migrate it to Delphi yet. But I think the simplest is to wait a little, I can add this feature in the next week to both FlexCel .NET and Delphi, and send you an updated copy.



Adrian - It sounds great!


Looking forward to testing,

- Steve

Hi,
It took a little longer than expected, but 6.7.2 is now released and it has copy to clipboard as html (please check the modified copy and paste demo).

It was way more complex than what I expected: I imagined that just copying the html in clipboard format would be enough. But then each program "understands" a different subset of html, even between different apps in office. So you tweaked the html so powerpoint would look fine, and word would look wrong. You tweaked it so word would look fine, and powerpoint would break again. And so on.

But well, with the above caveats, I think it is working really nice for word, powerpoint and some other apps I tested it with. It also doesn't copy images, since neither word or powepoint accept html5 embedded images. When you copy from Excel, Excel saves the images in a temp folder so the app pasting can read them, but that is a complete hack.

Here is an example of how a file looks in Excel 2016:



And here it is how it looks when copied with FlexCel and pasted in powerpoint:



And for the record, here it is how it looks in word:



I can't really guarantee this will look nice in any app (even office itself doesn't look nice many times when copying from one app and pasting in another in html, and in many cases FlexCel copied html looks better than Excel's copied html). But all in all, it seems fine.

Great - I'll give it a go. 


I assume it'll be easy, "to run FlexCelHtmlExport to a TStringStream, then copy it in "clipboard html". Is it also possible to copy to Biff6 and HTML at the same time?

Thanks,

Steve

[Quote]

I assume it'll be easy, "to run FlexCelHtmlExport to a TStringStream, then copy it in "clipboard html". Is it also possible to copy to Biff6 and HTML at the same time?
[QUOTE]

Actually, you now don't need to do that, that is what I added to the code, so you can now just use xls.CopyToClipboard to copy (in the 3 formats: text, html and biff8).

But make sure to look at the "Copy and Paste" demo in the "API" section of the examples, as it shows how to implement it. xls.CopytoClipboard does one part of the job (generating streams with the correct data for each of the formats). But you still need to actually copy that data to the clipboard (as this is different for firemonkey or vcl, we don't do it). The example mentioned shows the code needed for the 2 steps


Awesome Adrian - I'll take a close look!