We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using Excel to write the entire column including the heading

Writing column by column not row by row:

I used this(row by row), this will be for writing the entire row, I left out the first line, because of the heading:

            IWorksheet worksheet = workbook.Worksheets[0];//1. worksheet

            for (int i = 0; i < _excelObjekt.Count; i++)
            {
                worksheet.ImportArray(_excelObjekt[i], 2 + i, 1, false);
            }

But now I need generate an EXCEL without a physically file, actually from the memory( some kind of association between the heading and the data that belongs to it( heading and data should be from type of string).

I need  to write the entire column including the heading:
- the first line should be the heading and than it should be filled with the data, after the first column is filled the next column should be filled and so on, until everything is done.

How to do it ?


6 Replies

AV Abirami Varadharajan Syncfusion Team April 22, 2016 12:52 PM UTC

Hi Testname, 
 
Thank you for contacting Syncfusion support. 
 
Yes, it is possible to fill the data vertically using ImportArray method by setting isVertical parameter to true. The following code example illustrates this behaviour. 
 
Code Example: 
 
Worksheet.ImportArray(string[] array,int firstRow,int firstColumn, bool isVertical);
 
 
We have shared the sample for your reference which can be downloaded from the following link.  
 
 
Please let us know if you have any concerns. 
 
Regards, 
Abirami. 



TE Testname April 29, 2016 06:13 AM UTC

Good, but how can I format the first line(only heading) with bold and borders around it and for the entire document the default font should be verdana and default font size  10(including the first line).

With "actually from the memory"(first post), I meant not a MemoryStream, I wanted to have no physically template, building that structure without any templates from the memory.


AV Abirami Varadharajan Syncfusion Team May 2, 2016 10:07 AM UTC

Hi Testname, 
  
Thank you for updating us. 
  
Yes, you can format the first row of the imported data using CellStyle property. We have shared the sample as per your requirement which can be downloaded from the following link 
  
  
In this sample, we have created an Excel file instead of opening an existing template file to import data from the array. You can also refer the following UG documentation link to know more about applying styles in XlsIO. 
  
  
Please let us know if you have any concerns. 
  
Regards, 
Abirami. 



TE Testname May 3, 2016 06:35 AM UTC

Yes, but it will replace the result in middle not at the upper left corner, please fix it.


TE Testname May 3, 2016 10:32 AM UTC

Forget about my previous post, but how can I adjust that example to rearrange the column width with the largest column width in that column ?


DB Dilli Babu Nandha Gopal Syncfusion Team May 4, 2016 05:06 AM UTC

Hi Testname  

Yes, you can auto-fit the column width by using IRange.AutofitColumns method. The code example illustrating this behavior is available in the following UG documentation link.  


We have also shared a sample illustrating this behavior for your reference which can be downloaded from the following link.  
  

Please let us know if you have any concerns.  

Regards,  
Dilli babu. 


Loader.
Up arrow icon