Когда-то написал вот такой код - пытался учесть выделение "внутри" по вертикали/горизонтали. Вроде работает
X++:
void setRangeBorder(BookMark _bookMark,
int _lineStyle = 1, // xlContinuous
int _lineWeight = 1, // xlContinuous
boolean _inside = False,
int _workSheetNumber = 1,
container _lines2Draw = [true, true, true, true])
{
COM comRange, comBorders, comBorder, comWorkSheet;
TextBuffer textBuffer;
int fromRow;
int toRow;
;
try
{
comWorkSheet = this.getWorkSheet(_workSheetNumber);
comRange = comWorkSheet.Range(_bookMark);
if (comRange)
{
comBorders = comRange.Borders();
if (conPeek(_lines2Draw, 1))
{
comBorder = comBorders.Item(7); // left
comBorder.Weight(_lineWeight);
comBorder.LineStyle(_lineStyle);
}
if (conPeek(_lines2Draw, 2))
{
comBorder = comBorders.Item(8); // top
comBorder.Weight(_lineWeight);
comBorder.LineStyle(_lineStyle);
}
if (conPeek(_lines2Draw, 3))
{
comBorder = comBorders.Item(9); // bottom
comBorder.Weight(_lineWeight);
comBorder.LineStyle(_lineStyle);
}
if (conPeek(_lines2Draw, 4))
{
comBorder = comBorders.Item(10); // right
comBorder.Weight(_lineWeight);
comBorder.LineStyle(_lineStyle);
}
if (_inside)
{
textBuffer = new TextBuffer();
textBuffer.setText(_bookMark);
textBuffer.find('\\:');
if (textBuffer.matchPos() > 0 && textBuffer.matchLen() == 1)
{
textBuffer.find(@":a+");
fromRow = ZCH_ComExcelExportADO::colName2Num(textBuffer.subStr(textBuffer.matchPos(), textBuffer.matchLen()));
textBuffer.find(@":a+", textBuffer.matchPos() + textBuffer.matchLen());
toRow = ZCH_ComExcelExportADO::colName2Num(textBuffer.subStr(textBuffer.matchPos(), textBuffer.matchLen()));
if (fromRow < toRow)
{
comBorder = comBorders.Item(11); // inside vertical
comBorder.Weight(_lineWeight);
comBorder.LineStyle(_lineStyle);
}
textBuffer.find(@":d+");
fromRow = str2int(textBuffer.subStr(textBuffer.matchPos(), textBuffer.matchLen()));
textBuffer.find(@":d+", textBuffer.matchPos() + textBuffer.matchLen());
toRow = str2int(textBuffer.subStr(textBuffer.matchPos(), textBuffer.matchLen()));
if (fromRow < toRow)
{
comBorder = comBorders.Item(12); // inside horizontal
comBorder.Weight(_lineWeight);
comBorder.LineStyle(_lineStyle);
}
}
}
}
}
catch (exception::Error)
{
this.throwError("Ошибка такая-то");
}
}
Может кому-то пригодится