Posts

I've been using FlexCel for a large enterprise customer of mine for the past years in a couple projects and can only say it works incredibly well and even better, their support is top-notch, too - highly recommended!

Once you get APIMate, create the file in Excel, add the image, save, open the file in APIMate, and it will tell you the code you need to create the file.
should be similar to this
The code I get is the following:
XlsFile xls = new XlsFile(1, true);
//Images
using (FileStream fs = new FileStream("imagename.png", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
TImageProperties ImgProps = new TImageProperties();
ImgProps.Anchor = new TClientAnchor(TFlxAnchorType.MoveAndDontResize, 2, 13, 2, 16, 13, 13, 6, 208);
ImgProps.ShapeName = "Picture 1";
xls.AddImage(fs, ImgProps);
}

This is using the API. Using Reports, you would just drop an image in the template and name it something like "<#myimage>", then use FlexCelReport.AddValue("myImage", ByteArrayWithImage);

You can find more information about images in reports in the example: Demo\Modules\20.Reports\65.Images
(Note that you need to download the Windows version of FlexCel from our site to get this demo: http://www.tmssoftware.com/site/flexcelnet.asp If you are trying, instal the trial, if you buy in the component store, you get also a license to Windows FlexCel too, and you can get it from the registered users component in our page)

A final note: You specify an image in Excel by specifying the starting cell, the offset to the starting cell, an the ending cell and offset to the ending cell. But you can also specify image width and height. I'll paste an answer I gave in FlexCel forums last week about image aspect ratios that might be useful here:

Basically, you need to use the constructor of TClientAnchor that takes a width and a height, and FlexCel will calculate the ending rows and columns. (Excel always needs rows and columns, so TClientAnchor needs to calculate them.

Where imgHeight and imgWidth are the height an width of the image in "pixels". I wrote "pixels" in quotes because Excel doesn't deal with real pixels, but with resolution independent pixels instead. An image might have 640 pixels width, but the width in the screen will depend on the screen resolution.
So, now having this part, how do we calculate imgHeight and imgWidth.
You want imgWidth to be 5 columns. So you'll need to loop over all columns, sum their width, and divide by ExcelMetrics.ColMult to get the row in pixels. Then to keep the aspect ratio, imgHeight should be originalimageheight * newWidth/OriginalImageWidth
A full working example is below:
private double GetWidth(ExcelFile xls, int col1, int col2)
{
double Result = 0;
for (int c = col1; c < col2; c++)
{
Result += xls.GetColWidth(c, true);
}

Nice component, is it possible to create an excel file using your component from an existing populated Data base (on my app I´m using SQLite.Net)?. My App is on Xamarin.Android. I share with you a post a made asking for a component like your to complement my question.

You can do most things you want with the code, for example protect the sheet, or freeze the header row so when you scroll down it is fixed. To know how to do all this stuff, you create a file in Excel, do the things you want (for example freeze a row), and then open it in APIMate (the links for downloading APIMate for windows or OSX are in the Getting started page). APIMate will tell you the C# code you need to recreate the file you created in Excel in FlexCel.

2)Using Reports: This works a little different, and it is nice specially when you know the fields in advance that you want to export. For example, you could create an xls/x file in Excel and write in A2: <#Customer.Name>, in B2: <#Customer.Country>, etc, and then run a report using your SQLite db to fill in the tags. The advantage of the report approach is that your user can modify the template and add columns, or freeze the header row as in the case 1), but without touching the code. They only have to modify the template. I personally know some "power users" on some of my personal apps who learn how to create templates even if they can't code, and they can get some reports that I would not know how to do them. It is great because I send them basic reports, and then they can customize them as they wish. For example if the logo of the company changed, they just edit the template and change the logo.

For an example on how to do reports, please take a look at the "langwars" iOS demo: It reads a dataset from StackOverflow (of from a local file, depending on your settings), and then dumps it into an xls file which is later converted to html so it can be displayed in a web browser component.

There are about 50 examples which we sadly can't convert all to iOS and android, so you'll have to look at them in Windows. But they translate virtually unchanged to iOS.

Note also that if you decide to buy either on our site or in the component store, you'll get a license that is good for iOS, Android, Windows, OSX and very soon now Windows Store 8.1 (WinRT) and Windows Phone 8.

Well, I could keep speaking for years about this stuff, so I'll stop now If you have any more specific doubts, please don't hesitate to ask.

System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'FlexCel'.
at app7.Activity1..ctor () [0x00000] in c:\Users\Altaf\Documents\Projects\app7\app7\MainActivity.cs:18
at at (wrapper dynamic-method) object.cf5e2a59-0515-4370-85f8-dfc1218586b1 (intptr,object[])
at Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) [0x0006a] in /Users/builder/data/lanes/monodroid-lion-monodroid-4.6.6-branch/6d7480e9/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:141
at at (wrapper native-to-managed) Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr)
at

ALSO i CHECKED "WRITE_EXTERNAL_STORAGE" under android maifest . and i tried writing and reading to txt file over same device and it works fine ,