Hi All ,
How to change the cell width for excel export in asp.net ?
this is my sample code :
string style = @"";
Thanks in advance
Hi All ,
How to change the cell width for excel export in asp.net ?
this is my sample code :
string style = @"";
Thanks in advance
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Daniel WrightRank #2,947 · 489 reputationPosted May 8, 2025, 4:30 AM EDT
To change the cell width for Excel export in ASP.NET, you can modify the style attributes within your code snippet. In the provided sample code, the style definition seems to include a class called "textmode" with a specified font size and width. However, the width property may not directly affect the cell width in Excel.
To adjust the cell width for Excel export, you typically need to use specific Excel formatting properties. One common approach is to define the column width in the Excel file itself during export. Here's an example of how you can modify the code snippet to set the cell width:
// Define the Excel column width in the style string style = @" .textmode { mso-number-format:\@; font-size:15px; } .colWidth { mso-width-source:auto; mso-width-alt:200px; width:200px; } "; // Apply the style to your Excel content // Adjust the width based on your requirementsIn this adjusted code snippet, a new class "colWidth" is introduced to set the specific width for the Excel cell. You can customize the `width` property value to set the desired width for the Excel columns during export.
By incorporating the appropriate Excel styling within your ASP.NET application, you can effectively control the cell width for Excel exports. Make sure to test the exported Excel file to ensure that the cell widths meet your expectations. Let me know if you need further assistance or more detailed guidance on this topic!
Sangeetha SRank #212 · 11.4K reputationPosted May 8, 2025, 8:47 AM EDT
string table = @"