Problem with format a single excel column with OLE automation using Delphi -


I have a piece of code that I use to format several cells in Excel. It works fine in Excel 2007, but when the limit is only 1 column wide and Excel 2003 instead of 2007, I get an error saying that I am specifying an invalid value for line style of the border line.

** Valuables like "XL Insaestorious", I have declared them in permanent form with reasonable values.

Please help.

Process formula (frankolarov, farscole, toceloro, tococol: integer; topstyle, topcolor, topwight, botatestyle, bottomomcolor, bottomomewight, LEFTSTYLE, LEFTCOLOUR, LEFTWEIGHT, RIGHTSTYLE, RIGHTCOLOUR, RIGHTWEIGHT: integer; INNERVSTYLE, INNERVCOLOUR , INNERVWEIGHT: integer; INNERHSTYLE, INNERHCOLOUR, INNERHWEIGHT: integer; HORIZONTALCELLALIGNMENT: integer; fontBold: boolean; number format: string); Var TMPRange: variants; Start tmpRange: = eclApp.range [eclApp.Cells [FRCELLROW, FRCELLCOL], eclApp.Cells [TOCELLROW, TOCELLCOL]]; TmpRange.Borders [xlEdgeTop] Linstyl: = topmost; If TOPSTYLE & lt; & Gt; XlNone then starts tmpRange.Borders [xlEdgeTop] .colorIndex: = TOPCOLOUR; TmpRange.Borders [xlEdgeTop] Distraction: = TopWit; End; // if tmpRange.Borders [xlEdgeBottom]. Linstyl: = Botstyle; If Bottemapelle & lt; & Gt; XlNone then starts tmpRange.Borders [xlEdgeBottom]. Colorindex: = BOTTOMCOLOUR; TmpRange.Borders [xlEdgeBottom] Grammar: = BottomWight; End; // if tmpRange.Borders [xlEdgeLeft] Linstyl: = LEFTSTYLE; If LEFTSTYLE & lt; & Gt; XlNone then starts tmpRange.Borders [xlEdgeLeft]. Colorindex: = LEFTCOLOUR; TmpRange.Borders [xlEdgeLeft] Grammar: = left wight; End; // if tmpRange.Borders [xlEdgeRight] Linstyl: = Writely; If Rightstale & lt; & Gt; XlNone then starts tmpRange.Borders [xlEdgeRight]. Colorindex: = RIGHTCOLOUR; TmpRange.Borders [xlEdgeRight] Grammar: = right; End; // if tmpRange.Borders [xlInsideVertical] Linstyl: = INNERVSTYLE; If Investstale & lt; & Gt; XlNone then starts tmpRange.Borders [xlInsideVertical]. Colorindex: = INNERVCOLOUR; TmpRange.Borders [xlInsideVertical] Grammar: = INAVERWEIGHT; End; // if tmpRange.Borders [xlInsideHorizontal]. Linstyl: = INNERHSTYLE; If INNERHSTYLE & lt; & Gt; XlNone then starts tmpRange.Borders [xlInsideHorizontal] .colorIndex: INNERHCOLOUR; TmpRange.Borders [xlInsideHorizontal] Grammar: = INNERHWEIGHT; End; // if tmpRange.HorizontalAlignment: = HORIZONTAL cellulament; TmpRange.Font.Bold: = FontBold; TmpRange.NumberFormat: = NumberFormat; End; Similarly, if you have specified the height of the line "1", then you have specified the height of the line "1" D is the error. Internal styles are for lines between adjacent cells. A "1" column is not horizontally adjacent cell in the width range, so there is no vertical inner line. Excel 2007 is probably ignoring the invalid value, while Excel 2003 is throwing an error.

Before passing the values ​​of your "formatCells" process, test for the number of columns and the number of rows, and if you encounter "INNERVSTYLE, INNERVCOLOUR, INNERVWEIGHT" or "INNERHSTYLE, In place of "INNERHCOLOUR, INNERHWEIGHT", "1" in either of these "xlNone" (-4142).


Comments