HotXLS 문서

AddChartSheet 메서드

프로그래밍 방식으로 통합 문서에 BIFF8 차트 시트를 추가하고 새 TXLSWorksheet 탭을 반환합니다. 이전에는 차트 시트를 TXLSCustomChart를 통해 불투명하게 로드-저장 왕복 전용으로만 보존할 수 있었습니다. 이 메서드는 완전한 차트 하위 스트림을 SaveAs(xlExcel97)에 직접 씁니다. Excel은 결과를 요청한 종류의 차트 탭으로 엽니다. v2.41.0(로드맵 #10 1단계)부터 사용 가능하며, 시리즈 배열 오버로드는 v2.42.0에서 이어집니다

TXLSChartType 열거형

차트 종류를 선택합니다. 사용자 코드가 차트 빌더 유닛을 직접 가져올 필요가 없도록 lxHandle에서 다시 내보냅니다
type
  TXLSChartType = (
    xlsChartTypeColumn,
    xlsChartTypeBar,
    xlsChartTypeLine,
    xlsChartTypePie);

TXLSChartSeriesInfo 레코드

function AddChartSheet(AName: WideString; AChartType: TXLSChartType): TXLSWorksheet; overload;
type
  TXLSChartSeriesInfo = record
    Name        : WideString;
    Categories  : WideString;
    Values      : WideString;
  end;

구문

이 예제는 데이터 시트와 해당 데이터 시트의 두 열에 바인딩된 세로 막대형 차트가 있는 통합 문서를 만듭니다
// 1) v2.41.0 — name only; default column chart, no titles, no series.
function AddChartSheet(const Name: WideString): TXLSWorksheet;

// 2) v2.41.0 — name + chart type.
function AddChartSheet(
  const Name : WideString;
  ChartType   : TXLSChartType): TXLSWorksheet;

// 3) v2.41.0 — + chart title.
function AddChartSheet(
  const Name : WideString;
  ChartType   : TXLSChartType;
  const Title: WideString): TXLSWorksheet;

// 4) v2.41.0 — + category-axis title + value-axis title.
function AddChartSheet(
  const Name       : WideString;
  ChartType         : TXLSChartType;
  const Title      : WideString;
  const CatAxisTitle: WideString;
  const ValAxisTitle: WideString): TXLSWorksheet;

// 5) v2.42.0 — + array of series (Name + Categories range + Values range).
function AddChartSheet(
  const Name        : WideString;
  ChartType          : TXLSChartType;
  const Title       : WideString;
  const CatAxisTitle: WideString;
  const ValAxisTitle: WideString;
  const Series      : array of TXLSChartSeriesInfo): TXLSWorksheet;

비고

차트 종류별 서식 세부 정보는 아직 API에 노출되지 않았습니다


Series range binding (v2.47.0): starting in v2.47.0, the Categories and Values A1-range strings are compiled into real tArea3D cell-range references inside the BRAI, going through the formula compiler and the workbook EXTERNSHEET reference table. Before v2.47.0 these two fields were accepted on the API but emitted as cce=0 placeholders, so the rendered chart was empty. Existing v2.42.0 callers that left Categories / Values empty are unaffected

The returned TXLSWorksheet appears in the Sheets collection and gets a chart-sheet boundsheet entry written on save. Cell-level methods on the result are unsupported — the host worksheet is a chart container, not a data sheet

예제

This example builds a workbook with a data sheet and a column chart bound to two columns of that data sheet

var
  Series: array of TXLSChartSeriesInfo;
begin
  // Populate cells on Sheet1.
  Workbook.Sheets[1].Name := 'Data';
  // ... fill A1:B5 with categories + values ...

  SetLength(Series, 1);
  Series[0].Name       := 'Quarterly Revenue';
  Series[0].Categories := 'Data!$A$2:$A$5';
  Series[0].Values     := 'Data!$B$2:$B$5';

  Workbook.Sheets.AddChartSheet(
    'Revenue',
    xlsChartTypeColumn,
    'Quarterly Revenue',
    'Quarter',
    'USD',
    Series);

  Workbook.SaveAs('Revenue.xls', xlExcel97);
end;

제한 사항

Per-chart-type formatting details (gap width, bar overlap, pie hole size, marker style) are still emitted at the chart-builder defaults — not yet exposed on the API. Save-and-reopen with Excel preserves the chart sheet's presence, kind, title, axis titles, series captions, and (from v2.47.0) the series data binding

참조