Пример #1
0
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="document">Document to perform operations on</param>
 /// <param name="fullName">Full path name of document</param>
 public SpreadsheetDocument(OpenXmlSDK.SpreadsheetDocument document, string fullName)
     : base()
 {
     Document         = document;
     FullName         = fullName;
     InnerContent     = new SpreadsheetDocumentManager(this);
     Worksheets       = new WorksheetAccessor(this);
     Chartsheets      = new ChartsheetAccessor(this);
     CustomProperties = new CustomPropertiesAccesor(this);
     Tables           = new SpreadSheetTableAccesor(this);
     Style            = new SpreadSheetStyleAccessor(this);
 }
Пример #2
0
        /// <summary>
        /// Creates a new SpreadsheetDocument from a new or existing file
        /// </summary>
        /// <param name="filePath">Path of file</param>
        /// <param name="createNew">Whether create a new document or load from an existing one</param>
        public SpreadsheetDocument(string filePath, bool createNew)
        {
            try
            {
                if (createNew)
                {
                    Document = OpenXmlSDK.SpreadsheetDocument.Create(filePath, DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook);
                }
                else
                {
                    Document = OpenXmlSDK.SpreadsheetDocument.Open(filePath, true);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write(e.Message);
            }

            FullName         = filePath;
            InnerContent     = new SpreadsheetDocumentManager(this);
            Worksheets       = new WorksheetAccessor(this);
            Chartsheets      = new ChartsheetAccessor(this);
            CustomProperties = new CustomPropertiesAccesor(this);
        }