Examples of HSSFName


Examples of org.apache.poi.hssf.usermodel.HSSFName

  {
    try
    {
      for (Object anchorName : anchorNames.keySet())
      {
        HSSFName anchor = (HSSFName)anchorNames.get(anchorName);
        List linkList = (List)anchorLinks.get(anchorName);
        int index = anchor.getSheetIndex();
        anchor.setRefersToFormula("'" + workbook.getSheetName(index) + "'!"+ anchor.getRefersToFormula());
       
        if(linkList != null && !linkList.isEmpty())
        {
          for(Object hyperlink : linkList)
          {
            Hyperlink link = (Hyperlink)hyperlink;
            link.setAddress(anchor.getRefersToFormula());
          }
        }
       
      }
      for (Object pageIndex : pageLinks.keySet())
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    }
   
    String anchorName = textElement.getAnchorName();
    if(anchorName != null)
    {
      HSSFName aName = workbook.createName();
//      aName.setNameName(JRStringUtil.getJavaIdentifier(anchorName));
      aName.setSheetIndex(workbook.getSheetIndex(sheet));
      CellReference cRef = new CellReference(rowIndex, colIndex);
      aName.setRefersToFormula(cRef.formatAsString());
      anchorNames.put(anchorName, aName);
    }

    setHyperlinkCell(textElement);
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    // retrieve the named range
    int numberOfNames = wb.getNumberOfNames();

    // Get all the named ranges in our spreadsheet
    for (int namedRangeIdx = 0; namedRangeIdx < numberOfNames; namedRangeIdx++) {
      HSSFName aNamedRage = wb.getNameAt(namedRangeIdx);

      // retrieve the cell at the named range and test its contents
      AreaReference aref = new AreaReference(aNamedRage.getReference());
      CellReference[] crefs = aref.getAllReferencedCells();

      // A Range that we will put the new cells into
      Range redRange = new Range(aNamedRage.getNameName());

      for (int thisCellinRange = 0; thisCellinRange < crefs.length; thisCellinRange++) {
        HSSFSheet sheet = wb.getSheet(crefs[thisCellinRange]
            .getSheetName());
        HSSFRow r = sheet.getRow(crefs[thisCellinRange].getRow());
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

   
    //Get all names of *all* the cells in *all* the ranges
    Map<String,Cell> allCells =updatedValues.getAllCells();

    for (int namedCellIdx = 0; namedCellIdx < numberOfNames; namedCellIdx++) {
      HSSFName aNamedCell = wb.getNameAt(namedCellIdx);

      // retrieve the cell at the named range and test its contents
      AreaReference aref = new AreaReference(aNamedCell.getReference());
      CellReference[] crefs = aref.getAllReferencedCells();

      for (int thisCellinRange = 0; thisCellinRange < crefs.length; thisCellinRange++) {
        HSSFSheet sheet = wb.getSheet(crefs[thisCellinRange]
            .getSheetName());

        HSSFRow r = sheet.getRow(crefs[thisCellinRange].getRow());

        // Get the cell that is referred to
        HSSFCell excelCell = null;
        if (r != null) {
          excelCell = r.getCell(crefs[thisCellinRange].getCol());

          // Check that the range name is on our list
          String cellHandle = Range.getUniqueCellName(aNamedCell
              .getNameName(), thisCellinRange);

         
          if (allCells.containsKey(cellHandle)) {
            CellConvertor.convertCellToExcel(wb, excelCell,
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

            if(name.equalsIgnoreCase( book.getNameName(i) )) {
                return i;
            }
        }
       
        HSSFName nameObj = book.createName();
        nameObj.setNameName(name);
       
        return countNames;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

  }

  public void testNamedRangeThatLooksLikeCell() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");
    HSSFName name = wb.createName();
    name.setRefersToFormula("Sheet1!B1");
    name.setNameName("pfy1");

    Ptg[] ptgs;
    try {
      ptgs = HSSFFormulaParser.parse("count(pfy1)", wb);
    } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

  /** Named ranges with backslashes, e.g. 'POI\\2009' */
  public void testBackSlashInNames() {
    HSSFWorkbook wb = new HSSFWorkbook();

    HSSFName name = wb.createName();
    name.setNameName("POI\\2009");
    name.setRefersToFormula("Sheet1!$A$1");

    HSSFSheet sheet = wb.createSheet();
    HSSFRow row = sheet.createRow(0);

    HSSFCell cell_C1 =  row.createCell(2);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

  public void testParseComplexName() {

    // Mock up a spreadsheet to match the critical details of the sample
    HSSFWorkbook wb = new HSSFWorkbook();
    wb.createSheet("Sheet1");
    HSSFName definedName = wb.createName();
    definedName.setNameName("foo");
    definedName.setRefersToFormula("Sheet1!B2");

    // Set the complex flag - POI doesn't usually manipulate this flag
    NameRecord nameRec = TestHSSFName.getNameRecord(definedName);
    nameRec.setOptionFlag((short)0x10); // 0x10 -> complex
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    if (false) {
      // TODO - this code won't work until we can create user-defined functions directly with POI
      wb = new HSSFWorkbook();
      sheet = wb.createSheet();
      wb.setSheetName(0, "Sheet1");
      HSSFName hssfName = wb.createName();
      hssfName.setNameName("myFunc");
     
    } else {
      // This sample spreadsheet already has a VB function called 'myFunc'
      wb = HSSFTestDataSamples.openSampleWorkbook("testNames.xls");
      sheet = wb.getSheetAt(0);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFName

    /** bug 49725, defined names with underscore */
    public void testNamesWithUnderscore() {
        HSSFWorkbook wb = new HSSFWorkbook(); //or new XSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("NamesWithUnderscore");

        HSSFName nm;

        nm = wb.createName();
        nm.setNameName("DA6_LEO_WBS_Number");
        nm.setRefersToFormula("33");

        nm = wb.createName();
        nm.setNameName("DA6_LEO_WBS_Name");
        nm.setRefersToFormula("33");

        nm = wb.createName();
        nm.setNameName("A1_");
        nm.setRefersToFormula("22");

        nm = wb.createName();
        nm.setNameName("_A1");
        nm.setRefersToFormula("11");

        nm = wb.createName();
        nm.setNameName("A_1");
        nm.setRefersToFormula("44");

        nm = wb.createName();
        nm.setNameName("A_1_");
        nm.setRefersToFormula("44");

        HSSFRow row = sheet.createRow(0);
        HSSFCell cell = row.createCell(0);

        cell.setCellFormula("DA6_LEO_WBS_Number*2");
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.