Load() public method

Load the given file.
public Load ( string file ) : void
file string
return void
コード例 #1
0
		public void CreateSimpleTable()
		{
			//Create new spreadsheet document
			_spreadsheetDocument2		= new SpreadsheetDocument();
			_spreadsheetDocument2.Load(AARunMeFirstAndOnce.inPutFolder+@"blank.ods");
			//Create a new table
			Table table					= new Table(_spreadsheetDocument2, "First", "tablefirst");
			table.Rows.Add(new Row(table));
			//Create a new cell, without any extra styles 
			Cell cell								= new Cell(_spreadsheetDocument2, "cell001");
			cell.OfficeValueType					= "string";
			//Set full border
			cell.CellStyle.CellProperties.Border	= Border.NormalSolid;			
			//Add a paragraph to this cell
			Paragraph paragraph						= ParagraphBuilder.CreateSpreadsheetParagraph(
				_spreadsheetDocument2);
			//Add some text content
			String cellText = "Some text";
			paragraph.TextContent.Add(new SimpleText(_spreadsheetDocument2, cellText));
			//Add paragraph to the cell
			cell.Content.Add(paragraph);
			//Insert the cell at row index 2 and column index 3
			//All need rows, columns and cells below the given
			//indexes will be build automatically.
			table.InsertCellAt(1, 1, cell);
			//Insert table into the spreadsheet document
			_spreadsheetDocument2.TableCollection.Add(table);
			// Test inserted content
			Assert.AreEqual(_spreadsheetDocument2.TableCollection[0], table);
			String text = _spreadsheetDocument2.TableCollection[0].Rows[1].Cells[1].Node.InnerText;
			Assert.AreEqual(text, cellText);
		}
コード例 #2
0
ファイル: HTMLExportTest.cs プロジェクト: stuzzicadenti/aodl
 public void HTMLExportTest3()
 {
     string file							= AARunMeFirstAndOnce.inPutFolder+@"simpleCalc.ods";
     FileInfo fInfo						= new FileInfo(file);
     //Load a spreadsheet document
     SpreadsheetDocument document		= new SpreadsheetDocument();
     document.Load(file);
     //Save it back again
     document.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".html");
 }
コード例 #3
0
ファイル: Test1.cs プロジェクト: rabidbob/aodl-reloaded
		public void CellHasReferenceToRow()
		{
			string file = AARunMeFirstAndOnce.inPutFolder + @"bigtable.ods";
			SpreadsheetDocument textDocument = new SpreadsheetDocument();
			textDocument.Load(file);

			Table table = textDocument.Content[1] as Table;
			Row row = table.Rows[0];
			Cell cell = row.Cells[0];
			Assert.AreEqual(row, cell.Row);
			Assert.AreEqual(table, row.Table);
			
		}
コード例 #4
0
 public void ComplexCalcLoadTest()
 {
     string file							= AARunMeFirstAndOnce.inPutFolder+@"HazelHours.ods";
     FileInfo fInfo						= new FileInfo(file);
     //Load a spreadsheet document
     SpreadsheetDocument document		= new SpreadsheetDocument();
     try
     {
         document.Load(file);
         //Save it back again
         document.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".html");
     }
     catch(Exception ex)
     {
         if(ex is AODLException)
         {
             Console.WriteLine("Stacktrace: {0}", ((AODLException)ex).OriginalException.StackTrace);
             Console.WriteLine("Msg: {0}", ((AODLException)ex).OriginalException.Message);
             if(((AODLException)ex).Node != null)
                 Console.WriteLine("Stacktrace: {0}", ((AODLException)ex).Node.OuterXml);
         }
     }
 }
コード例 #5
0
		public void SpreadSheetImportExportTest()
		{
			//Create new spreadsheet document
			SpreadsheetDocument spreadsheetDocument		= new SpreadsheetDocument();
			spreadsheetDocument.Load(AARunMeFirstAndOnce.inPutFolder+@"bigtable.ods");
			ODFForm f = new ODFForm(spreadsheetDocument, "mainform");
			ODFButton butt = new ODFButton(f, spreadsheetDocument.TableCollection[0].Rows[1].Cells[1].Content, "butt", "5mm", "15mm", "4cm", "1cm");
			f.Controls.Add(butt);
			spreadsheetDocument.TableCollection[0].Forms.Add(f);
            spreadsheetDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"bigtable2.ods");
		}
コード例 #6
0
		public void SpreadSheetFormsTest()
		{
			//Create new spreadsheet document
			SpreadsheetDocument spreadsheetDocument		= new SpreadsheetDocument();
			spreadsheetDocument.New();
			//Create a new table
			Table table					= new Table(spreadsheetDocument, "First", "tablefirst");
			//Create a new cell, without any extra styles 
			Cell cell								= new Cell(spreadsheetDocument, "cell001");
			cell.OfficeValueType					= "string";
			//Set full border
			cell.CellStyle.CellProperties.Border	= Border.NormalSolid;			
			//Add a paragraph to this cell
			Paragraph paragraph						= ParagraphBuilder.CreateSpreadsheetParagraph(
				spreadsheetDocument);
			//Add some text content
			paragraph.TextContent.Add(new SimpleText(spreadsheetDocument, "Some text"));
			//Add paragraph to the cell
			cell.Content.Add(paragraph);
			//Insert the cell at row index 2 and column index 3
			//All need rows, columns and cells below the given
			//indexes will be build automatically.
			table.Rows.Add(new Row(table, "Standard"));
			table.Rows.Add(new Row(table, "Standard"));
			table.Rows.Add(new Row(table, "Standard"));
			table.InsertCellAt(3, 2, cell);
			//Insert table into the spreadsheet document
			
			ODFForm main_form = new ODFForm(spreadsheetDocument, "mainform");
			main_form.Method = Method.Get;
			ODFButton butt = new ODFButton(main_form, cell.Content, "butt", "0cm", "0cm", "15mm", "8mm");
			butt.Label = "test :)";
			main_form.Controls.Add (butt);
			spreadsheetDocument.TableCollection.Add(table);
			table.Forms.Add(main_form);
			
			spreadsheetDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"spreadsheet_forms.ods");

			SpreadsheetDocument spreadsheetDocument2		= new SpreadsheetDocument();
			spreadsheetDocument2.Load(AARunMeFirstAndOnce.outPutFolder+"spreadsheet_forms.ods");
			ODFButton b = spreadsheetDocument2.TableCollection[0].FindControlById("butt") as ODFButton;
			Assert.IsNotNull(b);
			b.Label = "it works!";
			spreadsheetDocument2.SaveTo(AARunMeFirstAndOnce.outPutFolder+"spreadsheet_forms2.ods");
		}
コード例 #7
0
		public void RowAndCellIterate() 
		{
			string file = AARunMeFirstAndOnce.inPutFolder+@"simpleCalc.ods";
			_spreadsheetDocument4 = new SpreadsheetDocument();
			_spreadsheetDocument4.Load(file);
			Assert.IsNotNull(_spreadsheetDocument4.TableCollection, "Table collection must exits.");
			Assert.IsTrue(_spreadsheetDocument4.TableCollection.Count == 3, "There must be 3 tables available.");
			int i = 0; // current row index
			int ii = 0; // current cell index
			string innerText = ""; // current inner text 
			try
			{
				Assert.IsTrue(_spreadsheetDocument4.TableCollection[0].Rows.Count == 6, "There must be 6 rows available.");
				for(i = 0; i < _spreadsheetDocument4.TableCollection[0].Rows.Count; i++) 
				{
					string contents = "Row " + i + ": ";
					Assert.IsTrue(_spreadsheetDocument4.TableCollection[0].Rows[i].Cells.Count == 3, "There must be 3 cells available.");
					for(ii = 0; ii < _spreadsheetDocument4.TableCollection[0].Rows[i].Cells.Count; ii++)
					{
						innerText = _spreadsheetDocument4.TableCollection[0].Rows[i].Cells[ii].Node.InnerText;
						if (_spreadsheetDocument4.TableCollection[0].Rows[i].Cells[ii].OfficeValue != null)
						{
							contents += _spreadsheetDocument4.TableCollection[0].Rows[i].Cells[ii].OfficeValue.ToString() + " ";
						} 
						else 
						{
							contents += innerText + " ";
						}
					}
					Console.WriteLine(contents);
				}
			}
			catch(Exception ex) 
			{
				string where = "occours in Row " + i.ToString() + " and cell " + ii.ToString() + " last cell content " + innerText + "\n\n";
				Console.WriteLine(where + ex.Message + "\n\n" + ex.StackTrace);
			}
		}
コード例 #8
0
		public void NewChartWithAxises()
		{
			SpreadsheetDocument doc = new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"testsheet.ods"));
			Table table = doc.TableCollection[0];
			Chart chart = ChartBuilder.CreateChartByAxises (table,"A1:B2",ChartTypes.line ,2);
			table.InsertChartAt ("I2",chart);
			doc.Content.Add (table);
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"NewChartWithAxis.ods"));
		}
コード例 #9
0
		public void SimpleCalcLoadTest()
		{
			string file							= AARunMeFirstAndOnce.inPutFolder+@"simpleCalc.ods";
			FileInfo fInfo						= new FileInfo(file);
			//Load a spreadsheet document
			SpreadsheetDocument document		= new SpreadsheetDocument();
			document.Load(file);
			Assert.IsTrue(document.CommonStyles.Count > 0, "Common Styles must be read!");
			Console.WriteLine("Common styles: {0}", document.CommonStyles.Count);
			//Save it back again
			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".rel.ods");
		}
コード例 #10
0
		public void TestPlotArea()
		{
			SpreadsheetDocument doc = new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"TestChartOne.ods"));
			Chart chart =(Chart)doc.EmbedObjects [0];
			chart.ChartPlotArea .SvgX ="1.2cm";
			chart.ChartPlotArea .SvgY ="2.5cm";
			chart.ChartPlotArea .Width ="5cm";
			chart.ChartPlotArea .Height ="5cm";
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"TestPlotArea.ods"));
		}
コード例 #11
0
		public void TestLengend()
		{
			SpreadsheetDocument doc = new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"TestChartOne.ods"));
			Chart chart = (Chart)doc.EmbedObjects [0];
			chart.ChartLegend .LegendPosition ="left";
			chart.ChartLegend .SvgX ="5cm";
			chart.ChartLegend .SvgY ="2cm";
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"TestLegend.ods"));

		}
コード例 #12
0
		public void LoadChartModifyTitle()
		{
			SpreadsheetDocument doc= new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"TestChartOne.ods"));
			IContent iContent = (EmbedObject)doc.EmbedObjects [0];
			((Chart)iContent).ChartTitle.SetTitle ("A New Title");
			((Chart)iContent).ChartTitle.SvgX ="2cm";
			((Chart)iContent).ChartTitle.SvgY ="0.5cm";
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"TestTitle.ods"));

		}
コード例 #13
0
		public void LoadChart()
		{
			SpreadsheetDocument doc= new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"TestChartOne.ods"));
			IContent iContent = (EmbedObject)doc.EmbedObjects [0];
			((Chart)iContent).ChartType =ChartTypes.bar.ToString ();
			((Chart)iContent).XAxisName ="XAxis";
			((Chart)iContent).YAxisName ="YAxis";
			((Chart)iContent).SvgWidth ="20cm";
			((Chart)iContent).SvgHeight ="20cm";
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"LoadChart.ods"));
		}
コード例 #14
0
		public void NewChartWithCellRange()
		{
			SpreadsheetDocument doc = new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"testsheet.ods"));
			Table table = doc.TableCollection[0];
			Chart chart = ChartBuilder.CreateChartByCellRange (table,"A4:F8",ChartTypes.bar ,null,null,"刘玉花的测试",3,"bottom","P14");
			table.InsertChartAt ("H2",chart);
			doc.Content.Add (table);
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"NewChartWithCellRange.ods"));

		}
コード例 #15
0
		public void NewChartWithLegend()
		{
			SpreadsheetDocument doc = new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"testsheet.ods"));
			Table table = doc.TableCollection[0];
			Chart chart = ChartBuilder.CreateChartByLegend (table,"A3:F8",ChartTypes.surface ,"left","0.5","5","year","dollars");
			table.InsertChartAt ("M2",chart);
			doc.Content.Add (table);
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"NewChartWithLegend.ods"));
		}
コード例 #16
0
		public void CsvToOpenDocumentSpreadsheet()
		{
			SpreadsheetDocument document		= new SpreadsheetDocument();
			document.Load(AARunMeFirstAndOnce.inPutFolder+"CsvToOpenDocument.csv");
			Assert.IsTrue(document.Content.Count == 1, "Must contain objects.");
			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"CsvToOpenDocument.ods");
		}
コード例 #17
0
		public void NewChartWithTitle()
		{
			SpreadsheetDocument doc = new SpreadsheetDocument ();
			doc.Load(Path.Combine(AARunMeFirstAndOnce.inPutFolder,@"testsheet.ods"));
			Table table = doc.TableCollection[0];
			Chart chart = ChartBuilder.CreateChartByTitle (table,"A3:E7",ChartTypes.stock,"北京红旗中文两千公司九月工资报表","0.5cm","0.5cm",null,null);
			chart.ChartTitle .TitleStyle.TextProperties .FontSize="3pt";
			chart.EndCellAddress =table.TableName +".P17";
			table.InsertChartAt ("I2",chart);
			doc.Content.Add (table);
			doc.SaveTo (Path.Combine(AARunMeFirstAndOnce.outPutFolder,"NewChartWithTitle.ods"));

		}
コード例 #18
0
		public void ComplexCalcLoadTest()
		{
			string file							= AARunMeFirstAndOnce.inPutFolder+@"HazelHours.ods";
			FileInfo fInfo						= new FileInfo(file);
			//Load a spreadsheet document
			SpreadsheetDocument document		= new SpreadsheetDocument();
			
			document.Load(file);
			//Save it back again
			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".html");
		}
コード例 #19
0
		public void CreateTableFormatedText()
		{
			//Create new spreadsheet document
			_spreadsheetDocument3		= new SpreadsheetDocument();
			_spreadsheetDocument3.Load(AARunMeFirstAndOnce.inPutFolder+@"blank.ods");
			//Create a new table
			Table table					= new Table(_spreadsheetDocument3, "First", "tablefirst");
			table.Rows.Add(new Row(table));
			//Create a new cell, without any extra styles 
			Cell cell								= table.CreateCell();
			cell.OfficeValueType					= "string";
			//Set full border
			//cell.CellStyle.CellProperties.Border	= Border.NormalSolid;			
			//Add a paragraph to this cell
			Paragraph paragraph						= ParagraphBuilder.CreateSpreadsheetParagraph(
				_spreadsheetDocument3);
			//Create some Formated text
			FormatedText fText						= new FormatedText(_spreadsheetDocument3, "T1", "Some Text");
			//fText.TextStyle.TextProperties.Bold		 = "bold";
			fText.TextStyle.TextProperties.Underline = LineStyles.dotted;
			//Add formated text
			paragraph.TextContent.Add(fText);
			//Add paragraph to the cell
			cell.Content.Add(paragraph);
			//Insert the cell at row index 2 and column index 3
			//All need rows, columns and cells below the given
			//indexes will be build automatically.
			table.InsertCellAt(2, 3, cell);
			//Insert table into the spreadsheet document
			_spreadsheetDocument3.TableCollection.Add(table);
			// Test inserted content
			Object insertedText = ((Paragraph)_spreadsheetDocument3.TableCollection[0].Rows[2].Cells[3].Content[0]).TextContent[0];
			Assert.AreEqual(fText, insertedText as FormatedText);
		}