public static XS__spreadsheet[] Load_fromURI( XS__RootMetadata root_ref_in, params Uri[] filePath_in ) { XS__spreadsheet[] _output = new XS__spreadsheet[filePath_in.Length]; for (int i = 0; i < filePath_in.Length; i++) { if (filePath_in[i].IsFile) { _output[i] = XS__spreadsheet.Load_fromFile( filePath_in[i].LocalPath )[0]; // no need! everything's been taken care at: XS__spreadsheet.Load_fromFile(...) //_output[i].root_spreadsheet_ = ROOT + "." + SPREADSHEET + "[" + i + "]"; //_output[i].parent_ref = root_ref_in; // ToDos: now! //if (root_ref_in != null) _output[i].root_ref = root_ref_in; } else { try { _output[i] = (XS__spreadsheet) new XmlSerializer(typeof(XS__spreadsheet)).Deserialize( OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL( filePath_in[i].ToString() ) ); } catch (Exception _ex) { throw new Exception(string.Format( System.Globalization.CultureInfo.CurrentCulture, "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}", typeof(XS__spreadsheet).Namespace, typeof(XS__spreadsheet).Name, //(filePath_in[i].IsFile) // ? filePath_in[i].LocalPath // : filePath_in[i].ToString(), _ex.Message )); } _output[i].root_spreadsheet_ = ROOT + "." + SPREADSHEET + "[" + i + "]"; _output[i].parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output[i].root_ref = root_ref_in; } } } return(_output); }
public XS__RootMetadata( #endif string metadataFilePath_in ) { string _metadataPath = System.IO.Path.GetDirectoryName(metadataFilePath_in); this.metadatafiles_ = Metadatas.Load_fromFile(metadataFilePath_in); #region int _total_xxx = ...; int _total_spreadsheet = 0; for (int f = 0; f < this.metadatafiles_.MetadataFiles.Count; f++) { switch (this.metadatafiles_.MetadataFiles[f].XMLFileType) { case XS__spreadsheet.SPREADSHEET: _total_spreadsheet++; break; } } #endregion #region string[] _xxxFilePath = new string[_total_xxx]; string[] _spreadsheetFilePath = new string[ _total_spreadsheet ]; #endregion _total_spreadsheet = 0; for (int f = 0; f < this.metadatafiles_.MetadataFiles.Count; f++) { switch (this.metadatafiles_.MetadataFiles[f].XMLFileType) { case XS__spreadsheet.SPREADSHEET: _spreadsheetFilePath[_total_spreadsheet] = System.IO.Path.Combine( _metadataPath, this.metadatafiles_.MetadataFiles[f].XMLFileName ); _total_spreadsheet++; break; } } this.spreadsheetcollection_ = new XS__spreadsheetCollection( XS__spreadsheet.Load_fromFile( (XS__RootMetadata)this, _spreadsheetFilePath ) ); }
public static void Main(string[] args) { #region string _ssFilePath = args[0]; string _spreadSheetFilePath; #if DEBUG if (args.Length != 1) { _spreadSheetFilePath = @"C:\Documents and Settings\Administrator\Desktop\TEST\Livro1.xlsx"; } else { _spreadSheetFilePath = args[0]; } #else if ( (args.Length != 1) ) { Console.WriteLine("invalid argument!"); } _ssFilePath = args[0]; if ( !System.IO.File.Exists(_ssFilePath) ) { Console.WriteLine("file not found!"); } #endif #endregion #region DataTable[] _datatable = XS__spreadsheet.Spreadsheet_toDataTable(...); DataTable[] _datatable = XS__spreadsheet.Spreadsheet_toDataTable( _spreadSheetFilePath ); if (_datatable == null) { return; } #endregion #region string _xmlFilePath = ...; string _xmlFilePath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(_spreadSheetFilePath), string.Format( System.Globalization.CultureInfo.CurrentCulture, "{0}.SpreadsheetXML.xml", System.IO.Path.GetFileNameWithoutExtension(_spreadSheetFilePath) ) ); #endregion XS__spreadsheet.DataTable_toXMLSpreadsheet( _datatable ).SaveState_toFile( _xmlFilePath ); #if DEBUG XS__spreadsheet _ss = XS__spreadsheet.Load_fromFile( _xmlFilePath )[0]; for (int p = 0; p < _ss.PageCollection.Count; p++) { Console.WriteLine("--- {0}", _ss.PageCollection[p].Name); for (int r = 0; r < _ss.PageCollection[p].RowCollection.Count; r++) { for (int c = 0; c < _ss.PageCollection[p].RowCollection[r].CellCollection.Count; c++) { Console.Write("{0}\t", _ss.PageCollection[p].RowCollection[r].CellCollection[c].Data); } Console.WriteLine(); } Console.WriteLine(); } #endif }