|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
||||
|
||||
Код - Некоторые констатны Excel и полезные мелочи
Нужно писать в одной из строк вертикально:
Через OLE: Код:
var c: Variant; begin c:=MyExcel.ActiveWorkbook.WorkSheets[1]; c.Range['5:5'].Orientation:=90; end; Через TExcelWorkSheet: Код:
var MyEWS: TExcelWorkSheet; begin ... MyEWS.Range['5:5'].Orientation:=90; ... end; Небольшой пример с установкой свойств ячеек в MS-Excel Код:
//Создаем вариантный массив TabGrid:=VarArrayCreate([1,RowCount,1,ColCount],varVariant); //Ориентация страницы WorkSheet.PageSetup.Orientation:=2; WorkSheet.PageSetup.LeftMargin:=4; WorkSheet.PageSetup.RightMargin:=4; //Размер ячейки (блока ячеек) WorkSheet.Range['L'+IntToStr(CurrLine),'L'+IntToStr(CurrLine)].Font.Size:=8; //Стиль шрифта WorkSheet.Range['L'+IntToStr(CurrLine),'L'+IntToStr(CurrLine)].Font.Bold:=False; WorkSheet.Range['L'+IntToStr(CurrLine),'L'+IntToStr(CurrLine)].Font.Italic:=False; //Выравнивание по горизонтали WorkSheet.Range[''L''+IntToStr(CurrLine),'L'+IntToStr(CurrLine)].HorizontalAlignment:=xlHAlignRight; //Выравнивание по вертикали WorkSheet.Range['L'+IntToStr(CurrLine),'L'+IntToStr(CurrLine)].VerticalAlignment:=xlVAlignTop; //Формат данных в ячейке WorkSheet.Range['L'+IntToStr(CurrLine),'L'+IntToStr(CurrLine)].NumberFormat:=''# ##0,00''; //Стиль границы WorkSheet.Range['L'+IntToStr(CurrLine),'L'+IntToStr(CurrLine)].Borders.LineStyle:=xlSolid; //Пример объединения ячеек WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].Font.Size:=12; WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].Font.Bold:=True; WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].HorizontalAlignment:=xlHAlignCenter; WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].VerticalAlignment:=xlVAlignTop; WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].WrapText:=True; WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].RowHeight:=12; WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].RowHeight:=25; WorkSheet.Range['A'+IntToStr(CurrLine),'N'+IntToStr(CurrLine)].Merge(True); //Связываем массив с сеткой Excel Worksheet.Range[''A1'',Worksheet.Cells.Item[RowCount,ColCount]].Value := TabGrid; // Отображаем Excel XLApp.Visible[0]:=True; //Ликвидируем вариантный массив XLApp.Disconnect; TabGrid:=Unassigned; При позднем связывании примерно так Код:
O: OleVariant; O:=CreateOleObject('Excel.Application'); // Параметры страницы O.ActiveSheet.PageSetup.LeftMargin:=O.CentimetersToPoints(1.5); O.ActiveSheet.PageSetup.RightMargin:=O.CentimetersToPoints(1); O.ActiveSheet.PageSetup.TopMargin:=O.CentimetersToPoints(1); O.ActiveSheet.PageSetup.BottomMargin:=O.CentimetersToPoints(1); O.ActiveSheet.PageSetup.Orientation:=$00000002; // xlLandscape V.ActiveSheet.PageSetup.Zoom:=100; // увеличение 100% O.ActiveSheet.PageSetup.PrintTitleRows:='$3:$3'; O.ActiveSheet.PageSetup.PrintTitleColumns:='$A:$A'; O.ActiveWindow.DisplayGridlines:=False; // Отключить сетку O.ActiveWindow.DisplayZeros:=False; // Не показывать нулевые значения const Код:
// XlColorIndex = ( xlColorIndexAutomatic = -4105; xlColorIndexNone = -4142; //это, похоже, относится к цвету линии xlGray25 = -4124; xlAutomatic = -4105; // XlLineStyle xlContinuous = 1; xlDash = -4115; xlDashDot = 4; xlDashDotDot = 5; xlDot = -4118; xlDouble = -4119; xlSlantDashDot = 13; xlLineStyleNone = -4142; //XlBorderWeight xlHairline = 1; xlMedium = -4138; xlThick = 4; xlThin = 2; // XlVAlign - вертикальное выравнивание ячеек xlVAlignBottom = -4107; xlVAlignCenter = -4108; xlVAlignDistributed = -4117; xlVAlignJustify = -4130; xlVAlignTop = -4160; // XlHAlign - горизонтальное выравнивание xlHAlignCenter = -4108; xlHAlignCenterAcrossSelection = 7; xlHAlignDistributed = -4117; xlHAlignFill = 5; xlHAlignGeneral = 1; xlHAlignJustify = -4130; xlHAlignLeft = -4131; xlHAlignRight = -4152; // XlBordersIndex xlInsideHorizontal = 12; xlInsideVertical = 11; xlDiagonalDown = 5; xlDiagonalUp = 6; xlEdgeBottom = 9; xlEdgeLeft = 7; xlEdgeRight = 10; xlEdgeTop = 8; xlLandscape = 2; xlPortrait =1; Форматы кодов и их описание: Код:
!!! &С, &К, &Д - страница, колво (всего), дата (dd,mm,yy) - только для русского MS-Office !!! Для English - &P, &N, &D &L - Left aligns the characters that follow. &C - Centers the characters that follow. &R - Right aligns the characters that follow. &E - Turns double-underline printing on or off. &X - Turns superscript printing on or off. &Y - Turns subscript printing on or off. &B - Turns bold printing on or off. &I - Turns italic printing on or off. &U - Turns underline printing on or off. &S - Turns strikethrough printing on or off. &A - Prints the name of the workbook tab. &D - Prints the current date. &F - Prints the name of the document. &P - Prints the page number. &N - Prints the total number of pages in the document. &T - Prints the current time. &P+number - Prints the page number plus the specified number. &P-number - Prints the page number minus the specified number. & "fontname" - Prints the characters that follow in the specified font. Be sure to include the double quotation marks. && - Prints a single ampersand. &nn -Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points. |