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

Specifying cells row and column

4 Answers 192 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
herb
Top achievements
Rank 1
Veteran
Iron
herb asked on 07 Mar 2021, 09:33 PM

I'm trying to build a worksheet header section with will be roughly six row.

Where cell A1 will have a fontsize of 20 and in green.

Cell D1 will be a date and time as a string.

Cell A2 will have some data, A3 blank, A4 some string, A5 some string.

Row 7 have the column header.

Not clear on how this work. My test code failed. Not understanding how Telerik walks through Cell's rows and column. Can you help with what documentation to read and samples to use?

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 09 Mar 2021, 12:28 PM

Hello Herb,

You can use the row/ column indexes to set the value and other properties of the cells. These are zero-based indexes so the A1 cell will have an index of 0,0. Here is an example that shows how you can set the properties of a cell: 

Workbook workbook = new Workbook();
var worksheet = workbook.Worksheets.Add();

worksheet.Cells[0, 0].SetValue("First Column");
worksheet.Cells[0, 0].SetFontSize(Unit.PointToDip(20));
worksheet.Cells[0, 0].SetForeColor(new ThemableColor(Colors.Green));

More information about this is available here: Get, Set and Clear Cell Properties.

You can find examples of this in the WPF demo applciation. There is an example in the GitHub repository as well: document-processing-sdk/DocumentGenerator.cs at master ยท telerik/document-processing-sdk

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
herb
Top achievements
Rank 1
Veteran
Iron
answered on 09 Mar 2021, 03:23 PM

Thank you Dimitar.

Other samples found where more out of *character* from the above. Having each write incase in a "using" statements.

using (IRowExporter row = worksheet.CreateRowExporter())
{
    row.SkipCells(2);///inside the "using" clause moves right 2 cells.
                                            ///note that each write before a space is its own using clause!!
    using (ICellExporter cell = row.CreateCellExporter())
    {
        cell.SetValue("Column 3, record " + i);
}
0
Dimitar
Telerik team
answered on 10 Mar 2021, 06:52 AM

Hi Herb,

These examples are for the RadSpreadStreamProcessing library. With this library, you are directly writing to a stream which improves the performance with very large files. Writing directly into a stream is complex and requires a different API and indeed it looks strange at first. More information about this library is available here: Overview.

Let me know if I can assist you further.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
herb
Top achievements
Rank 1
Veteran
Iron
answered on 10 Mar 2021, 02:10 PM
Thank you for the clarification.
Tags
Spreadsheet
Asked by
herb
Top achievements
Rank 1
Veteran
Iron
Answers by
Dimitar
Telerik team
herb
Top achievements
Rank 1
Veteran
Iron
Share this question
or