Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to calculate xlsx columns width from page coordinates?
How to calculate xlsx columns width from page coordinates? [message #1847812] Tue, 09 November 2021 06:53
Parth Bhatt is currently offline Parth BhattFriend
Messages: 2
Registered: November 2021
Junior Member
Hi All,

I am trying to write my custom Birt XSLX emitter as supdsoft emitter have some limitations. I am using birt 4.6 and it is working quite well, but when I try to calculate column width using page coordinates it's not calculated properly.

Could anyone let me know how to calculate it properly. Here is my below code:

@Override
public void endSheet(Page page, String orientation, int pageWidth, int pageHeight, float leftMargin,
float rightMargin, float topMargin, float bottomMargin) {
double[] coordinates = page.getCoordinates();
for (byte i = 0; i < coordinates.length; i++) {
this.sheet.setColumnWidth(i, (int) calulateWidth(coordinates[i]/1000.0D, 96) * 256);

}
}

public static double calulateWidth(double width, int dpi) {
float PX_PT = 72.0 / dpi;
if ( width < 0 )
return 0;

double result = 0;
double widthInPixel = width / PX_PT;
double digitalWidth = 7;

// convert from pixel to number of charaters
result = (int) ( ( widthInPixel - 5 ) / digitalWidth * 100 + 0.5 );
double characterNumber = (double) result / 100;

// calculate characterNumber
result = (int) ( ( characterNumber * digitalWidth + 5 ) / digitalWidth * 256 );
return result / 256;
}

If someone can help that will be great.

Regards,
Previous Topic:BIRT 2.5.1: IReportDocument.getPageNumber(bookMark) returns wrong page number?
Next Topic:Birt 4.7 / Tomcat 9 / MySQL / JVM 11 / Debian
Goto Forum:
  


Current Time: Mon Apr 29 02:55:06 GMT 2024

Powered by FUDForum. Page generated in 0.02995 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top