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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Using Excel to write the entire column including the heading

Thread ID:

Created:

Updated:

Platform:

Replies:

123783 Apr 21,2016 05:34 AM UTC May 4,2016 05:06 AM UTC ASP.NET MVC 6
loading
Tags: XlsIO
Testname
Asked On April 21, 2016 05:34 AM UTC

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 ?


Abirami Varadharajan [Syncfusion]
Replied On 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. 


Testname
Replied On 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.

Abirami Varadharajan [Syncfusion]
Replied On 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. 


Testname
Replied On 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.

Testname
Replied On 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 ?

Dilli Babu Nandha Gopal [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;