using System; using System.Collections.Generic; using System.Text; namespace Biff8Excel.Excel { public class ExternSheet : Interfaces.IExternSheet, IDisposable { Biff8Excel.Records.ExternSheet m_extern; ushort numRefs; Records.StructExternSheet[] marrRefs; ExcelWorkbook mWorkbook; internal byte[] WriteRecord() { m_extern.ExternSheets = marrRefs; return m_extern.GetByte(); } public ExcelWorkbook Workbook { set { mWorkbook = value; } } public ExternSheet() { m_extern = new Biff8Excel.Records.ExternSheet(); } #region IDisposable ³ΙΤ± public void Dispose() { marrRefs = null; m_extern = null; mWorkbook = null; } #endregion #region IExternSheet ³ΙΤ± public void SheetNameToIndex(string sSheetName, ref ushort iSheetIndex) { iSheetIndex = mWorkbook.SheetIndexFromName(sSheetName); } public ushort AddEntry(string fromSheet) { return AddEntry(fromSheet, ""); } public ushort AddEntry(string fromSheet, string toSheet) { ushort iFrom; ushort iTo; iFrom = mWorkbook.SheetIndexFromName(fromSheet); if (toSheet.Length == 0) { toSheet = fromSheet; iTo = iFrom; } else { iTo = mWorkbook.SheetIndexFromName(toSheet); } if (numRefs == 0) //marrRefs = TArray.Preserve(marrRefs, 1); Array.Resize(ref marrRefs, 1); else //marrRefs = TArray.Preserve(marrRefs, numRefs); Array.Resize(ref marrRefs, numRefs); // see if it already exists in the array for (ushort i = 0; i < numRefs; i++) { if (marrRefs[i].tFirstSheet == iFrom && marrRefs[i].tLastSheet == iTo) return i; } // add a new entry marrRefs[numRefs].tIndex = 0; marrRefs[numRefs].tFirstSheet = iFrom; marrRefs[numRefs].tLastSheet = iTo; numRefs++; return (ushort)(numRefs-1); } #endregion } }