This is a migrated thread and some comments may be shown as answers.

[Solved] Excel Biff export - formatting

3 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prathibarani
Top achievements
Rank 1
Prathibarani asked on 23 May 2013, 05:23 PM
Hi,

I am exporting grid data into an excel. I needed to add company logo at the top in excel. So, I did this:

string

 

 

imageURL = Page.ResolveUrl("~/Images/") + "Companylogo.jpg";
 
Radgrid1.ExportSettings.FileName = pFileName;

 

Telerik.Web.UI.ExportInfrastructure.

 

Table table = pExportEventArgs.ExportStructure.Tables[0];

 

xls.

 

Cell cmpCell = table.Cells["A1"];

 

table.InsertImage(cmpCell, imageURL);

table.ShiftRowsDown(1, 8);

Then I need to add some information to the sheet like this on row 9, from starting cell like this:
table.rows[9].cells[0]. value = "Down loaded from company name:" + current Date Time;

For this long text to appear as visible, I want to merge cells and then display.

From row 10, grid data gets displayed. If cell1 is not wide enough, row 9 value partially is visible.

How can I merge cells of particular row and add value to it.

I appreciate your response.

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 28 May 2013, 05:52 AM
Hello Prathibarani,

You can use the Colspan property of the Cell object. The default value is 1.
Let me know if you need more information.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Prathibarani
Top achievements
Rank 1
answered on 28 May 2013, 06:47 PM
Hi Daniel,

Thank you. That worked. I applied the same to the cell that I chose to insert. But image itself didn't show up. this is what I did.

string

 

 

imageURL = Page.ResolveUrl("~/Image/") + "companylogo.jpg"; Telerik.Web.UI.ExportInfrastructure.Table table = pExportEventArgs.ExportStructure.Tables[0];

 

table.Title = pWorkSheetName;

xls.

 

Cell cmpCell = table.Cells["A1"];
cmpCell.ColSpan = 4;

 

table.InsertImage(cmpCell, imageURL);

 

 

//table.InsertImage(new Microsoft.Office.Interop.Excel.Range("A1","C5"), imageURL);

 

table.ShiftRowsDown(1, 9);

Above code wouldn't insert image at all. I tried range. When I try the above commented line using range, it wouldn't event let me build.

Thanks,
Prathiba

0
Daniel
Telerik team
answered on 31 May 2013, 07:28 PM
Hello Prathiba,

The commented code won't work because the Interop Range object is not the same as ours. This is why I would recommend that you use an alias for the namespace. For example:
using ei = Telerik.Web.UI.ExportInfrastructure;
You can then try ei.Range, ei.Cell, and so on.
I'm not sure however what causes the issue in your scenario. Could you please prepare a small, runnable example that demonstrates the problem? I will debug it locally and then try to provide more to-the-point answer.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Prathibarani
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Prathibarani
Top achievements
Rank 1
Share this question
or