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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Including blank cells in worksheet

Thread ID:

Created:

Updated:

Platform:

Replies:

140793 Nov 7,2018 01:53 PM UTC Nov 9,2018 06:26 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: XlsIO
Mini Dev
Asked On November 7, 2018 01:53 PM UTC

Hi,
I need to include blank cell in worksheet but it does not work.
This is my code:

ExcelEngine excelEngine = new ExcelEngine();

IApplication application = excelEngine.Excel;

application.DefaultVersion = ExcelVersion.Excel2013;

IWorkbook workbook = application.Workbooks.Create(1);

IWorksheet worksheet = workbook.Worksheets[0];

 

worksheet[1, 1].Text = "";

worksheet[1, 2].Text = "";

       

using (FileStream fileStream = new FileStream(filePath, FileMode.CreateNew))

{           

    worksheet.SaveAs(fileStream, ";", Encoding.Default);                                                               

}

workbook.Close();

excelEngine.Dispose();           


Output expected: ;;


How can I fix? 



Prakash Kumar D [Syncfusion]
Replied On November 8, 2018 11:37 AM UTC

Hi Mini, 
 
Thank you for contacting Syncfusion support. 
 
It is not possible to include blank cells in an empty worksheet of Microsoft Excel (CSV format). You can include blank cells only in between cells with values. This is a behavior of Microsoft Excel, XlsIO does the same. 
 
However, you can achieve your requirement by using following code  
 
Code snippet: 
 
sheet["A1:C1"].Text = "blank cells"; 
sheet["A1:C1"].Text = ""; 
 
Note: In an empty worksheet, the used range of worksheet will be null in XlsIO. Hence the blank cells are not preserved. By assigning a text to a range, which will be included in used range and its preserve the blank cells. 
 
Regards, 
Prakash Kumar 


Mini Dev
Replied On November 8, 2018 11:40 AM UTC

there was a miss understanding.
I solved with 
worksheet.SetBlank();

Prakash Kumar D [Syncfusion]
Replied On November 9, 2018 06:26 AM UTC

Hi Mini, 
  
Thank you for updating us. 
  
We are glad that your issue is resolved. Please get back to us if you need further assistance. 
  
Regards, 
Prakash Kumar 


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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

;