<κλάση header="doc-nav" aria-label="Πλοήγηση τεκμηρίωσης"> Τεκμηρίωση HotXLS <κλάση nav="doc-links"> Περιεχόμενα Αρχική Επισκόπηση IXLSWorkbook TXLSWorksheets <κλάση div="nav topic-quick-nav" aria-label="Topic shortcuts"> Αρχική Περιεχόμενα Επισκόπηση

AddChartSheet μέθοδος

<κλάση div="indent"> <κλάση div="txt"> Programmatically appends a BIFF8 chart sheet to the workbook, returning the new TXLSWorksheet tab. Previously, chart sheets could only be preserved opaquely on a load-save round-trip via TXLSCustomChart; this method writes a complete chart substream directly into SaveAs(xlExcel97). Excel opens the result as a chart tab of the requested kind. Available since v2.41.0 (Roadmap #10 Phase 1); the array-of-series overload follows in v2.42.0

TXLSChartType enumeration

<κλάση div="indent"> <κλάση div="txt"> Selects the chart kind. Re-exported from lxHandle so user code does not need to import the chart-builder unit directly <κλάση pre="code"> type TXLSChartType = ( xlsChartTypeColumn, xlsChartTypeBar, xlsChartTypeLine, xlsChartTypePie);

TXLSChartSeriesInfo record

<κλάση div="indent"> <κλάση div="txt"> Carries a single series declaration for the 6-parameter overload. Categories and Values are A1-range strings (e.g. 'Sheet1!$B$2:$B$5') <κλάση pre="code"> type TXLSChartSeriesInfo = record Name : WideString; Categories : WideString; Values : WideString; end;

Σύνταξη

<κλάση div="indent"> <κλάση div="txt"> Five overloads cover progressively richer chart-sheet definitions: <κλάση pre="code"> // 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;

Παρατηρήσεις

<κλάση div="indent"> <κλάση div="txt"> The emitted chart substream covers the BIFF8 framing the spec calls for — BOF (dt=$0020), Chart / PlotGrowth / Frame / Series / SheetProperties / AxesUsed / AxisParent (POS + category axis + value axis + PlotArea + Frame + ChartFormat + chart-kind record + ChartFormatLink + Legend), EOF. Existing chart-sheet round-trip via TXLSCustomChart is unchanged
<κλάση div="txt"> Series name binding (v2.42.0): each non-empty Series[i].Name is written into the chart substream as a literal series label via a tStr PTG token on the series-name BRAI (id=2). Excel uses this label in the legend and series selector, so multi-series charts show proper captions instead of the default "Series1 / Series2" placeholders
<κλάση div="txt"> 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
<κλάση div="txt"> 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

Παράδειγμα

<κλάση div="indent"> <κλάση div="txt"> This example builds a workbook with a data sheet and a column chart bound to two columns of that data sheet
<κλάση pre="code"> 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;

Limitations

<κλάση div="indent"> <κλάση div="txt"> 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

Δείτε επίσης

<κλάση div="indent"> <κλάση div="txt"> κλάση TXLSWorksheets
IXLSWorkbook.Sheetsιδιότητα
TXLSXChart (XLSX side) <κλάση footer="reference-footer">Copyright © 2010-2026 losLab Software