Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gxoffice/src/main/java/com/genexus/gxoffice/ExcelCells.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class ExcelCells implements IExcelCells
public native long getColor();
public native void setColor(long nNewVal);

public native long getBackColor();
public native void setBackColor(long nNewVal);

public native double getSize();
public native void setSize(double nNewVal);

Expand Down
51 changes: 28 additions & 23 deletions gxoffice/src/main/java/com/genexus/gxoffice/IExcelCells.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
package com.genexus.gxoffice;
import java.util.*;

public interface IExcelCells
{
public double getNumber();
public Date getDate();
public String getText();
public String getValue();
import java.util.Date;

public void setNumber(double Value);
public void setDate(Date Value);
public void setText(String Value);
public interface IExcelCells {
public String getValue();

public String getFont();
public void setFont(String sNewVal);
public double getNumber();
public void setNumber(double Value);

public long getColor();
public void setColor(long nNewVal);
public Date getDate();
public void setDate(Date Value);

public double getSize();
public void setSize(double nNewVal);
public String getText();
public void setText(String Value);

public String getType();
public String getFont();
public void setFont(String sNewVal);

public short getBold();
public void setBold(short nNewVal);
public long getColor();
public void setColor(long nNewVal);

public short getItalic();
public void setItalic(short nNewVal);
public long getBackColor();
public void setBackColor(long nNewVal);

public short getUnderline();
public void setUnderline(short nNewVal);
public double getSize();
public void setSize(double nNewVal);

public String getType();

public short getBold();
public void setBold(short nNewVal);

public short getItalic();
public void setItalic(short nNewVal);

public short getUnderline();
public void setUnderline(short nNewVal);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.*;

import com.genexus.CommonUtil;
import com.genexus.gxoffice.IExcelCells;
import com.genexus.gxoffice.IGxError;
import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;

/**
* @author Diego
Expand Down Expand Up @@ -752,6 +753,45 @@ public void setColor(long value) // 05/07/05 B@tero
}
}

@Override
public long getBackColor() {
if (pCells.length == 0) {
return 0;
}

Cell cell = pCells[1];
if (cell.getCellStyle() == null) {
return 0;
}

return cell.getCellStyle().getFillForegroundColor();
}

@Override
public void setBackColor(long value) {
int val = (int) value;
int red = val >> 16 & 0xff;
int green = val >> 8 & 0xff;
int blue = val & 0xff;
XSSFColor newColor = new XSSFColor(new java.awt.Color(red, green, blue), null);

for (int i = 1; i <= cntCells; i++) {
Cell cell = pCells[i];
CellStyle cellStyle = cell.getCellStyle();
if (cellStyle == null) {
cellStyle = cell.getSheet().getWorkbook().createCellStyle();
}
if (cellStyle.getFillPattern() == FillPatternType.NO_FILL) {
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
}

((HSSFCellStyle)cellStyle).setFillForegroundColor(newColor.getIndexed());
cellStyle.setFillForegroundColor((short) value);
cell.setCellStyle(cellStyle);
}
}


private void copyPropertiesStyle(HSSFCellStyle dest, HSSFCellStyle source) {
dest.setAlignment(source.getAlignment());
dest.setBorderBottom(source.getBorderBottom());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@
import java.util.Date;
import java.util.GregorianCalendar;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.formula.functions.Index;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.*;

import com.genexus.CommonUtil;
import com.genexus.gxoffice.IExcelCells;
Expand Down Expand Up @@ -637,7 +629,11 @@ public void setColor(long value) // 05/07/05 B@tero
try {

for (int i = 1; i <= cntCells; i++) {
CellStyle cellStyle = pCells[i].getCellStyle();
Cell cell = pCells[i];
CellStyle cellStyle = cell.getCellStyle();
if (cellStyle == null) {
cellStyle = cell.getSheet().getWorkbook().createCellStyle();
}
Font fontCell = pWorkbook.getFontAt(cellStyle.getFontIndexAsInt());
CellStyle newStyle = null;
XSSFFont newFont = null;
Expand Down Expand Up @@ -731,6 +727,45 @@ public void setColor(long value) // 05/07/05 B@tero
}
}

@Override
public long getBackColor() {
if (pCells.length == 0) {
return 0;
}

Cell cell = pCells[1];
if (cell.getCellStyle() == null) {
return 0;
}

return cell.getCellStyle().getFillForegroundColor();
}

@Override
public void setBackColor(long value) {
int val = (int) value;
int red = val >> 16 & 0xff;
int green = val >> 8 & 0xff;
int blue = val & 0xff;

XSSFColor newColor = new XSSFColor(new java.awt.Color(red, green, blue),null);

for (int i = 1; i <= cntCells; i++) {
Cell cell = pCells[i];
CellStyle cellStyle = cell.getCellStyle();
if (cellStyle == null) {
cellStyle = cell.getSheet().getWorkbook().createCellStyle();
}

if (cellStyle.getFillPattern() == FillPatternType.NO_FILL) {
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
}

((XSSFCellStyle)cellStyle).setFillForegroundColor(newColor);
cell.setCellStyle(cellStyle);
}
}

protected void copyPropertiesStyle(CellStyle dest, CellStyle source) {
dest.cloneStyleFrom(source);
}
Expand Down