1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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<Records.tExternSheet>.Preserve(marrRefs, 1);
- Array.Resize<Records.StructExternSheet>(ref marrRefs, 1);
- else
- //marrRefs = TArray<Records.tExternSheet>.Preserve(marrRefs, numRefs);
- Array.Resize<Records.StructExternSheet>(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
- }
- }
|