Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [birt-dev] Birt Xlsx Emitter column width calculations

Parth,

We do not know what you are programming, we have no visuals, we do not know what the current and the expected result is.

With the information you supplied, I would say it is impossible to help you.

You can file issues here: https://github.com/eclipse/birt

On the issue, you must provide THE SHORTEST COMPLETELY REPRODUCIBLE test case with a clear description of what you are trying to achieve.

https://www.chiark.greenend.org.uk/~sgtatham/bugs.html

Cheers,

Wim



On Tue, Nov 9, 2021 at 8:40 AM Parth Bhatt <parth@xxxxxxxxxx> wrote:

Hi All,

I am trying to write my custom Birt XSLX emitter. 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,
--
Parth Bhatt | Sr. Software Engineer | www.aivhub.com
This message is confidential, so please treat it appropriately and for its intended purpose only. In particular, if it refers to any technical data, terms or prices not generally available or known, such items are "commercially sensitive information" within the terms of the Freedom of Information Act 2000 and related laws. As it would be prejudicial to AIVHUB Ltd commercial interests if these were disclosed, please refrain from doing so. As Internet communications are not secure, please be aware that AIVHUB Ltd cannot accept responsibility for its contents. Any views or opinions presented are those of the author only and not of AIVHUB Ltd. If you are not the intended recipient of this e-mail, please accept our apologies and arrange for copies of it to be deleted. For your information, AIVHUB Ltd may intercept incoming and outgoing email communications.
_______________________________________________
birt-dev mailing list
birt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/birt-dev

Back to the top