Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8414705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:14:03+00:00 2026-06-10T01:14:03+00:00

I have field called Comments in my DataTable which has few records more than

  • 0

I have field called “Comments” in my DataTable which has few records more than 255 characters.When we export the DataTable to Excel using the below code, the data is pushed into Excel but the Comments field record which has more than 255 characters overlaps other cells in Excel and the next column record is pushed to next row.

Code:

Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=XXXXXX.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
foreach (DataRow dr in dt.Rows){
tab = "";
for (int i = 0; i < dt.Columns.Count; i++){
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();

Can you guys please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:14:04+00:00Added an answer on June 10, 2026 at 1:14 am

    Use EPPlus excel library and create real excel files, it’s free and open source and works really well.

    I tested this scenario and fill cell with text longer than 4096 bytes, and it works OK, but with excel 2010 and xslx format.

    Here is the example code :

      ExcelPackage ePack = new ExcelPackage(new FileInfo("c:\\temp\\temp.xlsx"));
      ExcelWorksheet ws = ePack.Workbook.Worksheets.Add("Sheet1");
      string longText = "Lorem ipsum ..... <snipped>";
      ws.Cells[1, 1].Value = longText;
      ePack.Save();
    

    btw. you can find here example how to export DataTable to excel file :

    https://stackoverflow.com/a/9569827/351383

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which has a field called Sold , in that field
I have a field called system in my database which looks like this system
I have a custom field called HourField, which lets you enter 1:30 to represent
I have a struct that has a field called type How do i access
I have a class User with one field called birthDate which is a java.sql.Date
I have table called posts in my DB. Each post has field called social_network
I have an object which has one field- double[] _myField it's hashcode is public
I have a variable called $value in php which has a string value. When
I have a field called CreatedOn with values like : 2012-06-19 08:42:48.000 2012-06-19 08:43:05.000
Hi i am doing internal mail service application , i have the field called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.