Free Support Forum - aspose.com

AutoFitColumns in Excel file in Linux using Aspose.Cells for Java

Hi,

I am getting problems with autoFitColumns method when i run the code from linux.It works fine with windows environment.

cells.importArray(headers, 19, 0, false);
sheet.autoFitColumns(19, 0, 19, 27);

Exception trace

java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:1 34)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi ronment.java:62)
at java.awt.Font.initializeFont(Font.java:308)
at java.awt.Font.(Font.java:344)
at javax.swing.plaf.metal.DefaultMetalTheme$FontDelegate.getFont(Default MetalTheme.java:195)
at javax.swing.plaf.metal.DefaultMetalTheme.getFont(DefaultMetalTheme.ja va:153)
at javax.swing.plaf.metal.DefaultMetalTheme.getControlTextFont(DefaultMe talTheme.java:129)
at javax.swing.plaf.metal.MetalLookAndFeel$FontActiveValue.createValue(M etalLookAndFeel.java:1399)
at javax.swing.UIDefaults.getFromHashtable(UIDefaults.java:199)
at javax.swing.UIDefaults.get(UIDefaults.java:129)
at javax.swing.MultiUIDefaults.get(MultiUIDefaults.java:44)
at javax.swing.UIDefaults.getFont(UIDefaults.java:349)
at javax.swing.UIManager.getFont(UIManager.java:491)
at javax.swing.LookAndFeel.installColorsAndFont(LookAndFeel.java:89)
at javax.swing.plaf.basic.BasicLabelUI.installDefaults(BasicLabelUI.java :302)
at javax.swing.plaf.basic.BasicLabelUI.installUI(BasicLabelUI.java:254)
at javax.swing.JComponent.setUI(JComponent.java:449)
at javax.swing.JLabel.setUI(JLabel.java:238)
at javax.swing.JLabel.updateUI(JLabel.java:248)
at javax.swing.JLabel.(JLabel.java:141)
at javax.swing.JLabel.(JLabel.java:212)
at com.aspose.cells.dj.(Unknown Source)
at com.aspose.cells.b.a(Unknown Source)
at com.aspose.cells.b.(Unknown Source)
at com.aspose.cells.Worksheet.h(Unknown Source)
at com.aspose.cells.Worksheet.autoFitColumns(Unknown Source)

Please let me know about this issue.

Thanks

Joe

Hi,

Please try to set a Java environment variable when you run the application:

-Djava.awt.headless=true

Please refer to this post

http://www.aspose.com/Community/Forums/thread/69855.aspx

Thank you.

---------------------

Karen.huang
Developer
Aspose Nanjing Team
About Us
Contact Us

Thanks.It works perfect.