How to convert : Column unit to pixel in c#

@amjad.sahi , @Professionalize.Discourse , @John.He
Before set the unit column width in Excel, adjust according actual value set in the Excel output how if possible unit 14.806451612903226 to pixels

InEPPLUS library manages like this

//That below code added for stander width because when EPPlus set column width 14 after print check 13.29 set that's why adjust width.
if (columnWidth < 1)
{
	columnWidth = (12.0 / (double)worksheet.Workbook.MaxFontWidth) * columnWidth; // Adjust for widths less than 1
}
else
{
	columnWidth = columnWidth + (5.0 / (double)worksheet.Workbook.MaxFontWidth); // Adjust for widths greater than or equal to 1
}

@imparthgalani,

I am not entirely sure what you require, so I kindly request that you provide more details, along with sample files and screenshots, to clarify your needs. Please note, to convert Excel column widths (like 14.806451612903226) to pixels, and understand how EPPlus handles this internally, we need to understand both MS Excel’s column width logic and how EPPlus mimics it. MS Excel measures column width based on the number of characters of the default font that can fit in the cell.

Also, if you need to set column widht in pixels, please try to use the relevant method, e.g.,

Worksheet.Cells.SetColumnWidthPixel() 

Thanks for the quick reply.

I create documents and provide more information for this document. Please wait for some time.

@imparthgalani,

Sure, please take your time in providing the resource files and details. Once we have that samples and information, we will be able to evaluate your requirements and assist you more accurately.

1 Like