|
![]() |
#1 |
Участник
|
Когда-то написал вот такой код - пытался учесть выделение "внутри" по вертикали/горизонтали. Вроде работает
![]() 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("Ошибка такая-то"); } } |
|
![]() |
#2 |
Moderator
|
Цитата:
Сообщение от Gustav
![]() P.S. 2EAlex: Лихо-лихо Вы сообщения переставили. Теперь выглядит так, что я вроде как про 11 и 12 сам с собой поговорил
![]() А для операции обрамления можно использовать метод Range.BorderAround X++: _range.BorderAround( 1, COMVariant::createNoValue(), COMVariant::createNoValue(), WinAPI::RGB2int(0,0,0) ); |
|
![]() |
#3 |
Участник
|
|
|