当前位置: 首页>>代码示例>>Java>>正文


Java Cells.get方法代码示例

本文整理汇总了Java中com.aspose.cells.Cells.get方法的典型用法代码示例。如果您正苦于以下问题:Java Cells.get方法的具体用法?Java Cells.get怎么用?Java Cells.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.aspose.cells.Cells的用法示例。


在下文中一共展示了Cells.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	//Instantiating a Workbook object
    Workbook workbook = new Workbook();

	//Adding a new worksheet to the Workbook object
	WorksheetCollection worksheets = workbook.getWorksheets();
	Worksheet worksheet = worksheets.add("My Worksheet");
	
	Cells cells = worksheet.getCells();

	//Adding some value to cell
	Cell cell = cells.get("A1");
	cell.setValue("This is Aspose test of fonts!");

	//Saving the Excel file
    workbook.save("data/xlsx4j/newWorksheet_Aspose.xls");
    
    //Print Message
    System.out.println("Sheet added successfully.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:22,代码来源:NewSpreadSheetAspose.java

示例2: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
   	// Instantiating a Workbook object
       Workbook workbook = new Workbook();

       // Obtaining the reference of the first worksheet
       WorksheetCollection worksheets = workbook.getWorksheets();
       Worksheet sheet = worksheets.get(0);

       // Adding some sample value to cells
       Cells cells = sheet.getCells();
       Cell cell = cells.get("A1");
       cell.setValue(50);
       cell = cells.get("A2");
       cell. setValue (100);
       cell = cells.get("A3");
       cell.setValue(150);
       cell = cells.get("B1");
       cell.setValue(4);
       cell = cells.get("B2");
       cell.setValue(20);
       cell = cells.get("B3");
       cell.setValue(50);

       ChartCollection charts = sheet.getCharts();

       // Adding a chart to the worksheet
       int chartIndex = charts.add(ChartType.PYRAMID,5,0,15,5);
       Chart chart = charts.get(chartIndex);

       // Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
       SeriesCollection serieses = chart.getNSeries();
       serieses.add("A1:B3", true);

       // Saving the Excel file
       workbook.save("data/AsposeChart.xls");
       
       // Print message
       System.out.println("Workbook with chart is successfully created.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:41,代码来源:AsposeCharts.java

示例3: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	//Instantiating a Workbook object
	Workbook book = new Workbook();

	//Obtaining the reference of the newly added worksheet
	int sheetIndex = book.getWorksheets().add();
	Worksheet worksheet = book.getWorksheets().get(sheetIndex);
	Cells cells = worksheet.getCells();
	Cell cell = null;

	//Adding a value to "A1" cell
	cell = cells.get("A1");
	cell.setValue(1);

	//Adding a value to "A2" cell
	cell = cells.get("A2");
	cell.setValue(2);

	//Adding a value to "A3" cell
	cell = cells.get("A3");
	cell.setValue(3);

	//Adding a SUM formula to "A4" cell
	cell = cells.get("A4");
	cell.setFormula("=SUM(A1:A3)");

	//Calculating the results of formulas
	book.calculateFormula();

	//Saving the Excel file
	book.save("data/AsposeFormulaEngine.xls");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:34,代码来源:AsposeFormulaCalculationEngine.java

示例4: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithdata/gettingcellcontent/data/";
	
	Workbook workbook = new Workbook(dataPath + "workbook.xls");
	
	//Accessing the first worksheet in the Excel file
	Worksheet worksheet = workbook.getWorksheets().get(0);
	Cells cells = worksheet.getCells();
	
	//Access the Maximum Display Range
	Range range = worksheet.getCells().getMaxDisplayRange();
	int tcols = range.getColumnCount();
	int trows = range.getRowCount();
	
	System.out.println("Total Rows:" + trows);
	System.out.println("Total Cols:" + tcols);

	// Access value of Cell B4
	//=====================================================
	System.out.println(cells.get("B4").getValue());
	
	Cell cell = cells.get(3,1); //Access value of Cell B4
	System.out.println(cell.getValue());
	//=====================================================
	RowCollection rows = cells.getRows();
			
	for (int i = 0 ; i < rows.getCount() ; i++)
	{
		for (int j = 0 ; j < tcols ; j++)
		{
			if (cells.get(i,j).getType() != CellValueType.IS_NULL)
			{
				System.out.println(cells.get(i,j).getName() + " - " + cells.get(i,j).getValue());
			}
		}
	}
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:39,代码来源:AsposeGetCellContent.java

示例5: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithworkbook/adddataincells/data/";
	
	//Instantiating a Workbook object
	Workbook workbook = new Workbook();
	
	//Accessing the added worksheet in the Excel file
	Worksheet worksheet = workbook.getWorksheets().get(0);
	Cells cells = worksheet.getCells();
	
	cells.get("A1").setValue("Hello World"); //Adding a string value to the cell
	cells.get("A2").setValue(20.5); //Adding a double value to the cell
	cells.get("A3").setValue(15); //Adding an integer  value to the cell
	cells.get("A4").setValue(true); //Adding a boolean value to the cell
	
	Cell cell = cells.get("A5"); //Adding a date/time value to the cell
	cell.setValue(java.util.Calendar.getInstance());
	
	//Setting the display format of the date
	Style style = cell.getStyle();
	style.setNumber(15);
	cell.setStyle(style);
	
	workbook.save(dataPath + "DataInCells_Aspose_Out.xls"); //Saving the Excel file

	// Print message
	System.out.println("Data Added Successfully");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:30,代码来源:AsposeInsertCellsData.java

示例6: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithfonts/data/";
	
	//Instantiating a Workbook object
	Workbook workbook = new Workbook();

	//Accessing the worksheet in the Excel file
	Worksheet worksheet = workbook.getWorksheets().get(0);
	Cells cells = worksheet.getCells();

	//Adding some value to cell
	Cell cell = cells.get("A1");
	cell.setValue("This is Aspose test of fonts!");

	//Setting the font name to "Times New Roman"
	Style style = cell.getStyle();
	Font font = style.getFont();
	font.setName("Courier New");
	font.setSize(24);
	font.setBold(true);
	font.setUnderline(FontUnderlineType.SINGLE);
	font.setColor(Color.getBlue());
	font.setStrikeout(true);
	//font.setSubscript(true);

	cell.setStyle(style); 

	//Saving the modified Excel file in default format
	workbook.save(dataPath + "AsposeFonts.xls");
	
	System.out.println("Aspose Fonts Created.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:34,代码来源:AsposeWorkingWithFonts.java

示例7: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithborders/data/";
	
	//Instantiating a Workbook object
	Workbook workbook = new Workbook();

	//Accessing the worksheet in the Excel file
	Worksheet worksheet = workbook.getWorksheets().get(0);
	Cells cells = worksheet.getCells();

	//Accessing the "A1" cell from the worksheet      
	Cell cell = cells.get("B2");

	//Adding some value to the "A1" cell
	cell.setValue("Visit Aspose @ www.aspose.com!");
	Style style = cell.getStyle();

	//Setting the line of the top border
	style.setBorder(BorderType.TOP_BORDER,CellBorderType.THICK,Color.getBlack());

	//Setting the line of the bottom border
	style.setBorder(BorderType.BOTTOM_BORDER,CellBorderType.THICK,Color.getBlack());

	//Setting the line of the left border
	style.setBorder(BorderType.LEFT_BORDER,CellBorderType.THICK,Color.getBlack());

	//Setting the line of the right border
	style.setBorder(BorderType.RIGHT_BORDER,CellBorderType.THICK,Color.getBlack());

	//Saving the modified style to the "A1" cell.
	cell.setStyle(style);

	//Saving the Excel file
	workbook.save(dataPath + "AsposeBorders_Out.xls");

	System.out.println("Aspose Borders Created.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:39,代码来源:AsposeBorders.java

示例8: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	//Instantiating a Workbook object
	Workbook workbook = new Workbook("data/workbook.xls");
	
	Cells cells = workbook.getWorksheets().get(0).getCells();
	Cell cell = cells.get("A12");
	
	//Tracing precedents of the cell A12.
	//The return array contains ranges and cells.
	ReferredAreaCollection ret = cell.getPrecedents();
	
	//Printing all the precedent cells' name.
	if(ret != null)
	{
	  for(int m = 0 ; m < ret.getCount(); m++)
	  {
	    ReferredArea area = ret.get(m);
	    StringBuilder stringBuilder = new StringBuilder();
	    if (area.isExternalLink())
	    {
	        stringBuilder.append("[");
	        stringBuilder.append(area.getExternalFileName());
	        stringBuilder.append("]");
	     }
	     stringBuilder.append(area.getSheetName());
	     stringBuilder.append("!");
	     stringBuilder.append(CellsHelper.cellIndexToName(area.getStartRow(), area.getStartColumn()));
	     if (area.isArea())
	      {
	          stringBuilder.append(":");
	          stringBuilder.append(CellsHelper.cellIndexToName(area.getEndRow(), area.getEndColumn()));
	      }
	      System.out.println("Tracing Precedents: " + stringBuilder.toString());
	   }
	}
	
	//Get the A1 cell
	Cell c = cells.get("A5");
	//Get the all the Dependents of A5 cell
	Cell[] dependents = c.getDependents(true);
	for (int i = 0; i< dependents.length; i++)
	{
	     System.out.println("Tracing Dependents: " + dependents[i].getWorksheet().getName() +dependents[i].getName() + ":" + dependents[i].getIntValue());
	}
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:47,代码来源:TracingPrecedentsAndDependents.java

示例9: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithdata/hyperlink/data/";
	
	//Instantiating a Workbook object
	Workbook workbook = new Workbook();

	//Obtaining the reference of the first worksheet.
	WorksheetCollection worksheets = workbook.getWorksheets();
	Worksheet sheet = worksheets.get(0);
	HyperlinkCollection hyperlinks = sheet.getHyperlinks();

	//Adding a hyperlink to a URL at "A1" cell
	hyperlinks.add("A1",1,1,"http://www.aspose.com");

	//============ Link to Cell =================
	//Setting a value to the "A1" cell
	Cells cells = sheet.getCells();
	Cell cell = cells.get("A2");
	cell.setValue("Link to B9");

	setFormatting(cell);

	hyperlinks = sheet.getHyperlinks();

	//Adding an internal hyperlink to the "B9" cell of the other worksheet "Sheet1" in
	//the same Excel file

	hyperlinks.add("A2",1 ,1, "Sheet1!B9");
	
	//============ Link to External File ========
	
	cell = cells.get("A3");
	cell.setValue("External Link");

	setFormatting(cell);
	
	hyperlinks = sheet.getHyperlinks();

	//Adding a link to the external file
	hyperlinks.add("A3", 1, 1, "book1.xls");

	//Saving the Excel file
	//workbook.save("c:\\book2.xls");
	workbook.save(dataPath + "AsposeHyperlink.xls");
	
	System.out.println("Done ...");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:49,代码来源:AsposeHyperlinks.java

示例10: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithcolors/data/";
	
	//Instantiating a Workbook object
	Workbook workbook = new Workbook();

	//Accessing the added worksheet in the Excel file
	Worksheet worksheet = workbook.getWorksheets().get(0);
	Cells cells = worksheet.getCells();

	// === Setting Background Pattern ===
	
	//Accessing cell from the worksheet
	Cell cell = cells.get("B2");
	Style style = cell.getStyle();
	
	//Setting the foreground color to yellow
	style.setBackgroundColor(Color.getYellow());
	
	//Setting the background pattern to vertical stripe
	style.setPattern(BackgroundType.VERTICAL_STRIPE);
	
	//Saving the modified style to the "A1" cell.
	cell.setStyle(style);
	
	// === Setting Foreground ===
	
	//Adding custom color to the palette at 55th index
	Color color = Color.fromArgb(212,213,0);
	workbook.changePalette(color,55);
	
	//Accessing the "A2" cell from the worksheet
	cell = cells.get("B3");
	
	//Adding some value to the cell
	cell.setValue("Hello Aspose!");
	
	//Setting the custom color to the font
	style = cell.getStyle();
	Font font = style.getFont();
	font.setColor(color);
	
	cell.setStyle(style);
	
	//Saving the Excel file
	workbook.save(dataPath + "AsposeColors_Out.xls");
	
	System.out.println("Aspose Colors Created.");

}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:52,代码来源:AsposeWorkingWithColors.java

示例11: main

import com.aspose.cells.Cells; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithcharts/createcharts/data/";
	
	// Instantiating a Workbook object
       Workbook workbook = new Workbook();

       // Obtaining the reference of the first worksheet
       WorksheetCollection worksheets = workbook.getWorksheets();
       Worksheet sheet = worksheets.get(0);

       // Adding some sample value to cells
       Cells cells = sheet.getCells();
       Cell cell = cells.get("A1");
       cell.putValue(50);
       cell = cells.get("A2");
       cell. putValue (100);
       cell = cells.get("A3");
       cell.putValue(150);
       cell = cells.get("B1");
       cell.putValue(4);
       cell = cells.get("B2");
       cell.putValue(20);
       cell = cells.get("B3");
       cell.putValue(50);

       ChartCollection charts = sheet.getCharts();

       // Adding a chart to the worksheet
       int chartIndex = charts.add(ChartType.PYRAMID,5,0,15,5);
       Chart chart = charts.get(chartIndex);

       // Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
       SeriesCollection serieses = chart.getNSeries();
       serieses.add("A1:B3", true);

       // Saving the Excel file
       workbook.save(dataPath + "AsposeChart_Out.xls");
       
       // Print message
       System.out.println("Workbook with chart is successfully created.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:43,代码来源:AsposeCreateCharts.java


注:本文中的com.aspose.cells.Cells.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。