This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How Will You Set The Printable Area Of An Excel Using Apache Poi? |
|
Answer» Following code snippet demonstrate setting up the printable area of an EXCEL using Apache POI. XSSFWORKBOOK WORKBOOK = new XSSFWorkbook(); XSSFSheet spreadsheet = workbook .createSheet("PRINT Area"); //set print area with indexes workbook.setPrintArea( 0, //sheet index 0, //start column 5, //end column 0, //start ROW 5 //end row ); //set paper size spreadsheet.getPrintSetup().setPaperSize( XSSFPrintSetup.A4_PAPERSIZE); //set display grid lines or not spreadsheet.setDisplayGridlines(true); //set print grid lines or not spreadsheet.setPrintGridlines(true); Following code snippet demonstrate setting up the printable area of an excel using Apache POI. XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet spreadsheet = workbook .createSheet("Print Area"); //set print area with indexes workbook.setPrintArea( 0, //sheet index 0, //start column 5, //end column 0, //start row 5 //end row ); //set paper size spreadsheet.getPrintSetup().setPaperSize( XSSFPrintSetup.A4_PAPERSIZE); //set display grid lines or not spreadsheet.setDisplayGridlines(true); //set print grid lines or not spreadsheet.setPrintGridlines(true); |
|
| 2. |
How Will You Add A Hyperlink To A Cell Using Apache Poi? |
|
Answer» XSSFHyperlink can be used to the ADD an HYPERLINK to a cell. CreationHelper createHelper = workbook.getCreationHelper(); XSSFHyperlink link = (XSSFHyperlink)createHelper.createHyperlink(Hyperlink.LINK_URL); link.setAddress("HTTP://www.tutorialspoint.com/" ); cell.setHyperlink((XSSFHyperlink) link); XSSFHyperlink can be used to the add an hyperlink to a cell. CreationHelper createHelper = workbook.getCreationHelper(); XSSFHyperlink link = (XSSFHyperlink)createHelper.createHyperlink(Hyperlink.LINK_URL); link.setAddress("http://www.tutorialspoint.com/" ); cell.setHyperlink((XSSFHyperlink) link); |
|
| 3. |
How Will You Add A Sqrt Formular To A Cell Using Apache Poi? |
|
Answer» XSSFCell.CELL_TYPE_FORMULA can be used to the CELL as FORMULA cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("SQRT(C2)" ); cell = row.createCell(3); cell.setCellValue("SQRT(C2)"); XSSFCell.CELL_TYPE_FORMULA can be used to the cell as formula cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("SQRT(C2)" ); cell = row.createCell(3); cell.setCellValue("SQRT(C2)"); |
|
| 4. |
How Will You Add A Fact Formular To A Cell Using Apache Poi? |
|
Answer» XSSFCell.CELL_TYPE_FORMULA can be USED to the CELL as FORMULA cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("FACT(C2)" ); cell = row.createCell(3); cell.setCellValue("FACT(C2)"); XSSFCell.CELL_TYPE_FORMULA can be used to the cell as formula cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("FACT(C2)" ); cell = row.createCell(3); cell.setCellValue("FACT(C2)"); |
|
| 5. |
How Will You Add A Max Formular To A Cell Using Apache Poi? |
|
Answer» XSSFCell.CELL_TYPE_FORMULA can be used to the cell as FORMULA cell. cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("MAX(C2:C3)" ); cell = row.createCell(3); cell.setCellValue("MAX(C2:C3)"); XSSFCell.CELL_TYPE_FORMULA can be used to the cell as formula cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("MAX(C2:C3)" ); cell = row.createCell(3); cell.setCellValue("MAX(C2:C3)"); |
|
| 6. |
How Will You Add A Power Formular To A Cell Using Apache Poi? |
|
Answer» XSSFCell.CELL_TYPE_FORMULA can be used to the cell as FORMULA cell. // CREATE SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("POWER(C2:C3)" ); cell = row.createCell(3); cell.setCellValue("POWER(C2:C3)"); XSSFCell.CELL_TYPE_FORMULA can be used to the cell as formula cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("POWER(C2:C3)" ); cell = row.createCell(3); cell.setCellValue("POWER(C2:C3)"); |
|
| 7. |
How Will You Add A Sum Formular To A Cell Using Apache Poi? |
|
Answer» XSSFCell.CELL_TYPE_FORMULA can be used to the cell as FORMULA cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("SUM(C2:C3)" ); cell = row.createCell(3); cell.setCellValue("SUM(C2:C3)"); XSSFCell.CELL_TYPE_FORMULA can be used to the cell as formula cell. // Create SUM formula cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("SUM(C2:C3)" ); cell = row.createCell(3); cell.setCellValue("SUM(C2:C3)"); |
|
| 8. |
How Will You Rotate A Cell Content Using Apache Poi? |
|
Answer» XSSFCELLSTYLE CLASS can be used to rotate a cell. Following code snippet can be used to set the cell text ALIGNMENT to a SPECIFIED angle. //90 DEGREES XSSFCellStyle myStyle = workbook.createCellStyle(); myStyle.setRotation((short) 90); cell = row.createCell(5); cell.setCellValue("90D angle"); cell.setCellStyle(myStyle); XSSFCellStyle class can be used to rotate a cell. Following code snippet can be used to set the cell text alignment to a specified angle. //90 degrees XSSFCellStyle myStyle = workbook.createCellStyle(); myStyle.setRotation((short) 90); cell = row.createCell(5); cell.setCellValue("90D angle"); cell.setCellStyle(myStyle); |
|
| 9. |
How Will You Add A Font To A Cell Using Apache Poi? |
|
Answer» XSSFFONT CLASS is used to add a font to a cell. Following CODE snippet can be used to set the background color of a cell to "Green". //Create a new font and alter it. XSSFFont font = workbook.createFont(); font.setFontHeightInPoints((short) 30); font.setFontName("IMPACT"); font.setItalic(TRUE); font.setColor(HSSFColor.BRIGHT_GREEN.index); //Set font into style XSSFCellStyle style = workbook.createCellStyle(); style.setFont(font); XSSFFont class is used to add a font to a cell. Following code snippet can be used to set the background color of a cell to "Green". //Create a new font and alter it. XSSFFont font = workbook.createFont(); font.setFontHeightInPoints((short) 30); font.setFontName("IMPACT"); font.setItalic(true); font.setColor(HSSFColor.BRIGHT_GREEN.index); //Set font into style XSSFCellStyle style = workbook.createCellStyle(); style.setFont(font); |
|
| 10. |
How Will You Style A Cell Using Apache Poi? |
|
Answer» XSSFCellStyle class is USED to style a cell. Following CODE snippet can be used to set the cell ALIGNMENT to "Top Left". XSSFCellStyle style1 = workbook.createCellStyle(); spreadsheet.setColumnWidth(0, 8000); style1.setAlignment(XSSFCellStyle.ALIGN_LEFT); style1.setVerticalAlignment(XSSFCellStyle.VERTICAL_TOP); cell.setCellValue("Top Left"); cell.setCellStyle(style1); XSSFCellStyle class is used to style a cell. Following code snippet can be used to set the cell alignment to "Top Left". XSSFCellStyle style1 = workbook.createCellStyle(); spreadsheet.setColumnWidth(0, 8000); style1.setAlignment(XSSFCellStyle.ALIGN_LEFT); style1.setVerticalAlignment(XSSFCellStyle.VERTICAL_TOP); cell.setCellValue("Top Left"); cell.setCellStyle(style1); |
|
| 11. |
Write Down Steps To Create A Cell In A Spreadsheet In Apache Poi? |
|
Answer» The following code snippet is used for creating a CELL: //create NEW workbook XSSFWORKBOOK workbook = new XSSFWorkbook(); //create spreadsheet with a NAME XSSFSHEET spreadsheet = workbook.createSheet("new sheet"); //create first row on a created spreadsheet XSSFRow row = spreadsheet.createRow(0); //create first cell on created row XSSFCell cell = row.createCell(0); The following code snippet is used for creating a cell: //create new workbook XSSFWorkbook workbook = new XSSFWorkbook(); //create spreadsheet with a name XSSFSheet spreadsheet = workbook.createSheet("new sheet"); //create first row on a created spreadsheet XSSFRow row = spreadsheet.createRow(0); //create first cell on created row XSSFCell cell = row.createCell(0); |
|
| 12. |
Write Down Steps To Create A Spreadsheet In Apache Poi? |
|
Answer» The FOLLOWING CODE snippet is used to CREATE a spreadsheet: //Create Blank WORKBOOK XSSFWORKBOOK workbook = new XSSFWorkbook(); //Create a blank spreadsheet XSSFSheet spreadsheet = workbook.createSheet("Sheet Name"); Write down steps to create a row in a spreadsheet in Apache POI. The following code snippet is used to create a row. XSSFRow row = spreadsheet.createRow((short)1); The following code snippet is used to create a spreadsheet: //Create Blank workbook XSSFWorkbook workbook = new XSSFWorkbook(); //Create a blank spreadsheet XSSFSheet spreadsheet = workbook.createSheet("Sheet Name"); Write down steps to create a row in a spreadsheet in Apache POI. The following code snippet is used to create a row. XSSFRow row = spreadsheet.createRow((short)1); |
|
| 13. |
What Is The Purpose Of Xssfprintsetup Class In Apache Poi? |
|
Answer» This is a CLASS under the org.apache.poi.xsssf.usermodel package. It implements the PrintSetup INTERFACE. It is used to set PRINT PAGE size, area, OPTIONS, and settings. This is a class under the org.apache.poi.xsssf.usermodel package. It implements the PrintSetup interface. It is used to set print page size, area, options, and settings. |
|
| 14. |
What Is The Purpose Of Xssfcreationhelper Class In Apache Poi? |
|
Answer» This is a class under the org.apache.poi.xssf.usermodel package. It implements the CreationHelper interface. It is used as a support class for FORMULA evaluation and setting up HYPERLINKS. This is a class under the org.apache.poi.xssf.usermodel package. It implements the CreationHelper interface. It is used as a support class for formula evaluation and setting up hyperlinks. |
|
| 15. |
What Is The Purpose Of Xssfhyperlink Class In Apache Poi? |
|
Answer» This is a CLASS under the org.apache.poi.xssf.usermodel PACKAGE. It IMPLEMENTS the HYPERLINK interface. It is used to set a hyperlink to the CELL contents of a spreadsheet. This is a class under the org.apache.poi.xssf.usermodel package. It implements the Hyperlink interface. It is used to set a hyperlink to the cell contents of a spreadsheet. |
|
| 16. |
What Is The Purpose Of Xssffont Class In Apache Poi? |
|
Answer» This is a CLASS under the org.apache.poi.xssf.usermodel package. It implements the Font INTERFACE and therefore it can handle DIFFERENT fonts in a workbook. This is a class under the org.apache.poi.xssf.usermodel package. It implements the Font interface and therefore it can handle different fonts in a workbook. |
|
| 17. |
What Is The Purpose Of Hssfcolor Class In Apache Poi? |
|
Answer» This is a class under the org.apache.poi.hssf.util package. It provides DIFFERENT COLORS as nested classes. Usually these nested classes are REPRESENTED by USING their own indexes. It implements the Color INTERFACE. This is a class under the org.apache.poi.hssf.util package. It provides different colors as nested classes. Usually these nested classes are represented by using their own indexes. It implements the Color interface. |
|
| 18. |
What Is The Purpose Of Xssfcellstyle Class In Apache Poi? |
|
Answer» This is a class under the org.apache.poi.xssf.usermodel PACKAGE. It will PROVIDE possible information regarding the FORMAT of the content in a cell of a spreadsheet. It also provides options for MODIFYING that format. It implements the CellStyle INTERFACE. This is a class under the org.apache.poi.xssf.usermodel package. It will provide possible information regarding the format of the content in a cell of a spreadsheet. It also provides options for modifying that format. It implements the CellStyle interface. |
|
| 19. |
What Is The Purpose Of Xssfcell Class In Apache Poi? |
|
Answer» This is a class under the org.apache.poi.xssf.usermodel package. It implements the Cell interface. It is a high-level REPRESENTATION of CELLS in the rows of a SPREADSHEET. This is a class under the org.apache.poi.xssf.usermodel package. It implements the Cell interface. It is a high-level representation of cells in the rows of a spreadsheet. |
|
| 20. |
What Is The Purpose Of Xssfrow Class In Apache Poi? |
|
Answer» This is a CLASS under the org.apache.poi.xssf.usermodel package. It implements the Row INTERFACE, therefore it can CREATE rows in a SPREADSHEET. This is a class under the org.apache.poi.xssf.usermodel package. It implements the Row interface, therefore it can create rows in a spreadsheet. |
|
| 21. |
What Is The Purpose Of Xssfsheet Class In Apache Poi? |
|
Answer» This is a class which represents HIGH LEVEL representation of EXCEL spreadsheet. It is under org.apache.poi.hssf.usermodel PACKAGE. This is a class which represents high level representation of excel spreadsheet. It is under org.apache.poi.hssf.usermodel package. |
|
| 22. |
What Is The Purpose Of Hssfsheet Class In Apache Poi? |
|
Answer» This is a CLASS under the org.apache.poi.hssf.usermodel package. It can CREATE EXCEL spreadsheets and it allows to FORMAT the sheet STYLE and sheet data. This is a class under the org.apache.poi.hssf.usermodel package. It can create excel spreadsheets and it allows to format the sheet style and sheet data. |
|
| 23. |
What Is The Purpose Of Xssfworkbook Class In Apache Poi? |
|
Answer» It is a class that is used to REPRESENT both high and low level Excel file FORMATS. It belongs to the org.apache.xssf.usemodel package and implements the Workbook INTERFACE. It is a class that is used to represent both high and low level Excel file formats. It belongs to the org.apache.xssf.usemodel package and implements the Workbook interface. |
|
| 24. |
What Is The Purpose Of Hssfworkbook Class In Apache Poi? |
|
Answer» It is a high-level CLASS under the org.apache.poi.hssf.usermodel package. It IMPLEMENTS the Workbook interface and is used for Excel files in .XLS FORMAT. It is a high-level class under the org.apache.poi.hssf.usermodel package. It implements the Workbook interface and is used for Excel files in .xls format. |
|
| 25. |
Name Some Of The Components Of Apache Poi? |
|
Answer» Components of Apache POI: Apache POI contains classes and METHODS to work on all OLE2 Compound documents of MS Office. The list of components of this API is given below. POIFS (Poor Obfuscation Implementation File System) − This component is the basic factor of all other POI elements. It is used to read different files EXPLICITLY.
Components of Apache POI: Apache POI contains classes and methods to work on all OLE2 Compound documents of MS Office. The list of components of this API is given below. POIFS (Poor Obfuscation Implementation File System) − This component is the basic factor of all other POI elements. It is used to read different files explicitly. |
|
| 26. |
What Is Apache Poi? |
|
Answer» Apache POI is a popular API that allows programmers to CREATE, modify, and DISPLAY MS Office FILES using JAVA programs. It is an open source library developed and distributed by Apache Software Foundation to design or modify Microsoft Office files using Java program. It CONTAINS classes and methods to decode the user input data or a file into MS Office documents. Apache POI is a popular API that allows programmers to create, modify, and display MS Office files using Java programs. It is an open source library developed and distributed by Apache Software Foundation to design or modify Microsoft Office files using Java program. It contains classes and methods to decode the user input data or a file into MS Office documents. |
|