HotXLS 문서

XLSX Facade 개요 (lxHandleX)

lxHandleX는 Excel 2007+(.xlsx) 및 OpenDocument Spreadsheet(.ods) 통합 문서 워크플로를 위한 전용 파사드(facade) 유닛입니다. 기존 lxHandle 파사드와 공존하여 기존 코드가 아무런 변경 없이 계속 작동할 수 있도록 합니다

클래스 계층 구조

XLSX 파사드는 다음 클래스들을 노출합니다

type
  TXLSXWorkbook           = class  // top-level workbook with SaveAs / Open
  TXLSXHtmlExportOptions  = class  // HTML document, style, BOM, and table class options
  TODSExportOptions        = class  // ODS export options for generator, chart, and image output
  TXLSXSheets             = class  // worksheet collection on the workbook
  TXLSXFonts              = class  // workbook-level font palette
  TXLSXFont               = class  // single font descriptor
  TXLSXFills              = class  // workbook-level fill palette
  TXLSXFill               = class  // single fill (pattern + fg/bg color)
  TXLSXBorders            = class  // workbook-level border palette
  TXLSXBorder             = class  // four edges + diagonal border
  TXLSXNumberFormats      = class  // workbook-level custom format codes
  TXLSXDefinedNames       = class  // workbook-level named ranges
  TXLSXWorksheet          = class  // single worksheet with cells and decorations
  TXLSXStructuralEditRegistry = class  // ordered application participants for row and column reference updates
  TXLSXCells              = class  // cell collection on the worksheet
  TXLSXCell               = class  // single cell (value, formula, *Index style refs)
  TXLSXRange              = class  // rectangular worksheet range wrapper
  TXLSXMergedCells        = class  // merged-range collection
  TXLSXHyperlinks         = class  // hyperlink collection
  TXLSXComments           = class  // cell-comment collection
  TXLSXImages             = class  // image collection (drawings + media)
  TXLSXConditionalFormats = class  // conditional formatting rules
  TXLSXDataValidations    = class  // data-validation rules
  TXLSXTables             = class  // Excel-style table collection
  TXLSXCharts             = class  // chart collection (anchored or full-page)
  TXLSXChart              = class  // single or combination chart with primary, secondary, date, value, and series axes
  TXLSXChartPlotGroup     = class  // ordered chart-family group with its own series and axis pair
  TXLSXChartSeries        = class  // chart series with formula ranges and typed literal caches
  TXLSXTextBox            = class  // standalone worksheet drawing text box
  TXLSXRichText           = class  // per-run rich-text payload for cells
  TXLSXAlignment          = class  // cell alignment / wrap / indent / rotation
  TXLSXExternalLinks      = class  // external workbook link collection
  TXLSXExternalLink       = class  // single external workbook reference (Target URL + SheetNames)
  TXLSConnections                                              = class  // external data connection collection
  TXLSConnection                                               = class  // database, web, text, and refresh connection metadata
  TXLSQueryTables                                              = class  // worksheet query-result collection
  TXLSQueryTable                                               = class  // query ownership, fields, and result binding
      

이 클래스들은 lxHandle.TXLSWorkBook 및 lxHandle.TXLSWorksheet와 독립적입니다. 두 형식이 모두 필요한 애플리케이션은 두 파사드를 함께 사용할 수 있습니다

uses
  lxHandle,   // XLS / HTML / RTF / CSV workbook (TXLSWorkBook)
  lxHandleX;  // XLSX workbook (TXLSXWorkbook)
      

빠른 시작

XLSX 파사드는 BIFF 파사드와 동일한 호출 규칙을 따릅니다 — 통합 문서에서의 SaveAs / Open, 워크시트 컬렉션에서의 Sheets.Add / Sheets[i], 그리고 셀 컬렉션에서의 Cells.Item[Row, Col].Value입니다. 아래의 예제는 현재 지원되는 모든 기능을 실행하는 간단한 통합 문서를 작성합니다

uses lxHandleX;

var
  wb: TXLSXWorkbook;
  ws: TXLSXWorksheet;
  bold, yellow, box, currency: Integer;
begin
  wb := TXLSXWorkbook.Create;
  try
    bold     := wb.Fonts.Add('Calibri', 12, True, False);
    yellow   := wb.Fills.AddSolid($FFFFFF00);
    box      := wb.Borders.AddBox(xlsxBorderThin);
    currency := wb.NumberFormats.Add('"$"#,##0.00');

    ws := wb.Sheets.Add('Demo');
    ws.Cells.Item[1, 1].Value := 'Hello';
    ws.Cells.Item[1, 1].FontIndex := bold + 1;
    ws.Cells.Item[1, 2].Value := 123.45;
    ws.Cells.Item[1, 2].NumberFormatIndex := currency + 1;
    ws.Cells.Item[2, 1].Value := Now;                 // tagged as date
    ws.Cells.Item[2, 2].Formula := 'SUM(B1:B1)';
    ws.Cells.Item[3, 1].FillIndex := yellow + 1;      // highlight cell
    ws.Cells.Item[3, 2].BorderIndex := box + 1;       // boxed cell
    ws.ColWidth[1] := 24;
    ws.RowHeight[1] := 28;
    ws.MergeCells(4, 1, 4, 3);
    ws.Range['A8:C10'].Merge(True);                  // merge across rows
    ws.AddHyperlink(5, 1, 'https://www.loslab.com', 'Visit losLab');
    ws.AddComment(5, 2, 'Important note', 'Kevin');
    ws.AddImageFromFile(6, 1, 'logo.png');
    ws.AddConditionalFormat('B1:B10', xlsxCfOpGreaterThan, '100');
    ws.AddListValidation('C1:C5', 'Yes,No,Maybe');
    wb.DefinedNames.Add('SalesData', 'Demo!$A$1:$B$10');
    wb.SaveAs('demo.xlsx');
  finally
    wb.Free;
  end;
end;
      

지원되는 기능

파사드 하위 컬렉션 API

파사드 컬렉션 클래스는 조건부 서식, 데이터 유효성 검사, 명명된 범위, 이미지 및 테이블을 관리합니다. 다음은 각 컬렉션의 핵심 멤버입니다

지원되는 기능

공유 인프라

두 파사드는 공통적인 하위 수준 도우미 유닛 세트를 공유하므로 스타일 설명자, 해시 테이블, AVL 트리, ZIP 및 XML I/O, RGB-to-HLS 변환 및 문자열 빌더가 한 번만 작성되어 양쪽 경로에서 모두 사용됩니다. 공유 도우미에는 다음이 포함됩니다

참고 항목