About HtmlSaveOptions.setExportGridLines and cell's border

@craig.w.su

Thanks for your runnable sample code and it is good to know that you were able to successfully download the most recent version.

If you like, please let us know what made you successfully download the files, because it will be a useful information for us and for other Aspose users.

Download Links for Output HTML and Sample Code Java File:

custom.zip (13.2 KB)
Sample Code Java File.zip (1.4 KB)

We were able to observe this issue and logged it in our database for investigation and for a fix.

This issue has been logged as

  • CELLSJAVA-42347 - Color of grid lines in output HTML is wrong and not like original file

I downloaded it with my phone, and then send to Pushbullet.

@craig.w.su

OK. Thanks for the valuable information. It means, attachments are downloadable via Smart Phones.

I downloaded from your Dropbox link, but the attachment in the forum still give me HTTP 500, even with my smart phone

@craig.w.su

Thanks for the information.

@craig.w.su,

This issue is caused by cell initiation. When the cell is not created, the right border of cell can’t gain the left border of right cell, the lineStyle of borders is none. So you can get the correct result after changing your function accordingly.
Please use the following sample code to change the borders:
e.g
Sample code:

static void fixCellStyle42347(Workbook book) 
{
	StyleFlag styleFlagGrid = new StyleFlag();
	styleFlagGrid.setBorders(true);
	
	for (int i = 0; i < book.getWorksheets().getCount(); i++)
	{
		Worksheet sheet = book.getWorksheets().get(i);
		int maxRow = sheet.getCells().getMaxRow();
		int maxCol = sheet.getCells().getMaxColumn();
	
		for (int datai = 0; datai <= maxRow; datai++) 
		{
			for (int datay = 0; datay <= maxCol; datay++) 
			{
				Cell dataCell = sheet.getCells().get(datai, datay);
				Style dataStyle = dataCell.getStyle();
				
				Cell rightCell = null;
				Style rightStyle = null;
				if (datay < maxCol)
				{
					rightCell = sheet.getCells().get(datai, datay + 1);
					rightStyle = rightCell.getStyle();
				}
	
				if (dataStyle.getBorders().getByBorderType(BorderType.LEFT_BORDER).getLineStyle() == 0)
				{
					dataStyle.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.fromArgb(204, 204, 204));
				}
				if (dataStyle.getBorders().getByBorderType(BorderType.RIGHT_BORDER).getLineStyle() == 0) 
				{
					if(! (rightCell != null && rightStyle.getBorders().getByBorderType(BorderType.LEFT_BORDER).getLineStyle() != 0))
					{
						dataStyle.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN,
								Color.fromArgb(204, 204, 204));
					}									
				}
				if (dataStyle.getBorders().getByBorderType(BorderType.BOTTOM_BORDER).getLineStyle() == 0) 
				{
					dataStyle.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN,
							Color.fromArgb(204, 204, 204));
				}
				if (dataStyle.getBorders().getByBorderType(BorderType.TOP_BORDER).getLineStyle() == 0) 
				{
					dataStyle.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.fromArgb(204, 204, 204));
				}
				dataCell.setStyle(dataStyle, styleFlagGrid);
				dataCell.getStyle().setNumber(49);
			}
		}
	}
}