We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Inconsistent Cell Formatting

The following code creates inconsistent results when formatting cells with the Aspose.Cells 7.0.3 jar.

I realize the cells are getting formatted in a non-sequential fashion, but our code is by design to be this way.

Thanks,
Frank

import java.io.IOException;

import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.Style;
import com.aspose.cells.TextAlignmentType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AutoFitProblem
{
public static void main(String[] args) throws IOException, Exception
{
final Workbook wb = new Workbook();
createSheet(wb, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 });
final int index = wb.getWorksheets().add();
wb.getWorksheets().setActiveSheetIndex(index);
createSheet(wb, new int[] { 3, 1, 2, 0, 4, 16, 10, 22, 9, 8, 12, 5, 6, 23, 25 });
wb.save(“c:\temp\aspose.xls”);
}

public static void createSheet(final Workbook wb, final int[] order)
{
final Worksheet ws = wb.getWorksheets().get(wb.getWorksheets().getActiveSheetIndex());
final Cells cells = ws.getCells();

for (int c=0; c<order.length; c++)
{
final int column = order[c];
final Cell cell = cells.get(0, column);
cell.setValue(cell.getName() + " XXXX XXXXXXXXXX XXXXXXXXX XX XXXXXXXXXX XXXXXX XXXXXXX XXXXXXXXXXXX XXXXXXXXXXXX");
final Style style = cell.getStyle();
style.setTextWrapped(true);
style.setVerticalAlignment(TextAlignmentType.CENTER);
style.setHorizontalAlignment(TextAlignmentType.CENTER_ACROSS);
cell.setStyle(style);
ws.autoFitColumn(column, 0, 0);
}
}
}

Hi,


After an initial test, I can find the issue as you have mentioned.
Using your code, the generated file has problems regarding inconsistency in the two sheets, We need to investigate the issue first, we will do it soon.

I have logged a ticket with an id: CELLSJAVA-40059. We will look into it soon.

Thank you.

Hi,

We have fixed this issue. Please download: Aspose.Cells for Java v7.0.3.6

The issues you have found earlier (filed as CELLSJAVA-40059) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.