single sheet export to XLS file

Hello
Currently the demo shows exporting an entire workbook to an XLS file.

Q1. What I want to do is export just one single sheet in an workbook to a XLS file - how do I do it?
Q2. How do I manipulate what columns / rows are exported to that XLS file?

---------

Interestingly the print demo I have allows me to manipulate what columns/rows are printed on to the selected single sheet - exactly what I want to do with an export.

But I cannot see a quick way to print to an XLS file rather than paper - is it possible?

Is there documentation / demo on this somewhere ?

Thanks

Hi,

I am not really sure I understand the question, can you expand a little more?

A workbook in FlexCel is a memory representation of an xls file, you aren't exporting it. If you want to load an xls file with say 5 sheets and only save one, you could just FlexCelImport.DeleteSheet the sheets you don't want. And then delete the columns/rows you don't want, and then save the new xls file. But you always have a direct mapping between what you have in memory and what will be saved. You can't just save a part of it.

Hello Adrian

I will try and explain...

I have a flexcellimport and a flexcellgrid in which through code i create multiple sheets with different cell content.

I now want to just save one sheet as an excel file.

The excel file will essentially be an export of data which can be imported into 3rd party applications.
Those 3rd party applications have a strict requirement for the file to contain just certain columns and the columns order to be correct.

so just the ability to save a selected single sheet from a work book as an XLS file would be great start.

The next step I would like to do is give the user the option to choose the columns and the order that they will appear inside the outputted XLS file, so that they can build the XLS file to match the required import format of the 3rd party application.

For example one 3rd party application needs to import a file with the columns arranged like so...
C | F | A | B | V

Another 3rd party application may only need the following columns
H | R | A

I hope that helps explain what I am trying to achieve.

Thanks
 
PS. I followed you on Twitter today!


Ah, ok.

We don't really provide a way to export from xls to xls, because as said, you already have an xls file in memory, and so the way to get this would be to remove the parts that you don't want from it. 

So my solutions would be either:
1) You could save the FlexCelImport to a stream, open it in a different FlexCelImport, and there delete the sheets and columns to get the file you need. But as you will need to reorder columns, this might not be ideal.

2) Given your requirements (column reordering, validation of the contents, etc) what I would do,personally, is just to create a new empty FlexCelImport, and manually copy the values from one to the other in a loop. This way you can validate the values, and also write the values in the new FlexCelImport in the way you need them.

In FlexCel 5 there might be a shortcut since you can InsertAndCopyRanges form one file to another, but even then, what InsertAndCopyRange does is to loop over the cells and set the values. So I think it is better to do it yourself, so you can also validate the values while copying. 2 simple loops (in rows and columns) with a FlexCelImport2.CellValue[r, c] := FlexCelImport1[r, c]; in the middle should do.

then just save FlexCelImport2

btw, thanks for following me in twitter!  ;)

I don't really know what it is good for, but announcing FlexCel releases might be a good use.