Is it possible to specify formatting for the cells or rows in the Excel file when inserting?
In particular, I would like to format the header differently from the values.
-Edwin S. Ramirez-
|
>In particular, I would like to format the header differently from the values.
The simplest solution is preparing a blank .xls file which has that format. If you wish to insert column names too, you can use FirstRowHasNames=false connection property to do that.
>Is it possible to specify formatting for the cells or rows in the Excel file
> when inserting?
It's possible, but how to provide that feature through JDBC API. What's your want? fontName, fontSize, isItalic, colour, scriptStyle, underlineStyle, and/or boldWeight? We can complement that feature through some sql functions, for instance, setCellColour. You should email us an expectant format sample so that we can see whether we can complement that feature.
|
Your first solution only works if I know what the header should contain ahead of time, which I won't.
Ideally, the Excel driver would provide the ability to define a style to use for each of the columns that are going to be inserted. For example:
db.setFont(1, "Times New Roman");
db.setSize(1, "14");
Where the first argument is the Excel cell. Or even better:
db.setStyle(1, "font=Times New Roman;size=14;fontWeight=bold;colspan=3;");
The next insert would use the predefined styles to format the cells. Of course, chainging the style of the same cells after rows have been writen, would only change the following rows.
Hope this helps!
-Edwin S. Ramirez-
|
>db.setStyle(1, "font=Times New Roman;size=14;fontWeight=bold;colspan=3;");
Good idea. Maybe a sql function,
setCellStyle(cXlsFileName,cSheetName,columnIndex,rowIndex,cStyle);//which cstyle can use "font=Times New Roman;size=14;fontWeight=bold;colspan=3;"
or
update sheet1 set _Style_="column=A;font=Times New Roman;size=14;fontWeight=bold;colspan=3;" where recno()=3;
I prefer using a specila column name for style change. What's your suggestion?
|
I see where you are going, and I think is good. But we are looking at the problem from two different points of view. On the one hand, we could define style for the cells before we write them. While on the other hand, we could define the style after the rows have been written.
Considering that all the rows in each sheet (table) in the excel file will have the same structure, your update statement approach is very useful.
I guess a similar statement can be used to defined the header style (when the header was added directly by the driver).
Thanks,
-Edwin S. Ramirez-
|