1010import  org .apache .poi .ss .usermodel .DateUtil ;
1111import  org .apache .poi .ss .usermodel .Drawing ;
1212import  org .apache .poi .ss .usermodel .Sheet ;
13- import  org .apache .poi .ss .usermodel .Workbook ;
1413import  org .apache .poi .xssf .usermodel .XSSFCell ;
1514
1615/** 
17-  * @author abhis  
16+  * @author abhishek sarkar  
1817 * 
1918 */ 
2019public  class  Utility  {
@@ -28,33 +27,35 @@ public static boolean hasContent(XSSFCell cell) {
2827	}
2928
3029	@ SuppressWarnings ("rawtypes" )
31- 	public  static  void  addComment (Workbook  workbook , Sheet  sheet , int  rowIndex , XSSFCell  cell1 , String  author , XSSFCell  cell2 ) throws  Exception  {
30+ 	public  static  void  processDiff (XSSFCell  cell1 , XSSFCell  cell2 , boolean  commentFlag ) throws  Exception  {
31+ 32+ 		Sheet  sheet  = cell1 .getSheet ();
3233
3334		System .out .println (String .format ("Diff at cell[%s] of sheet[%s]" , cell1 .getReference (), sheet .getSheetName ()));
3435
3536		ExcelDiffChecker .diffFound  = true ;
3637
37- 		if (!ExcelDiffChecker . commentFlag ) {
38+ 		if (!commentFlag ) {
3839			System .out .println (String .format ("Expected: [%s], Found: [%s]" , getCellValue (cell1 ), getCellValue (cell2 )));
3940			return ;
4041		}
4142
42- 		CreationHelper  factory  = workbook .getCreationHelper ();
43+ 		CreationHelper  factory  = sheet . getWorkbook () .getCreationHelper ();
4344	 //get an existing cell or create it otherwise: 
4445
4546	 ClientAnchor  anchor  = factory .createClientAnchor ();
4647	 //i found it useful to show the comment box at the bottom right corner 
4748	 anchor .setCol1 (cell1 .getColumnIndex () + 1 ); //the box of the comment starts at this given column... 
4849	 anchor .setCol2 (cell1 .getColumnIndex () + 3 ); //...and ends at that given column 
49- 	 anchor .setRow1 (rowIndex  + 1 ); //one row below the cell... 
50- 	 anchor .setRow2 (rowIndex  + 5 ); //...and 4 rows high 
50+ 	 anchor .setRow1 (cell1 . getRowIndex ()  + 1 ); //one row below the cell... 
51+ 	 anchor .setRow2 (cell1 . getRowIndex ()  + 5 ); //...and 4 rows high 
5152
5253	 Drawing  drawing  = sheet .createDrawingPatriarch ();
5354	 Comment  comment  = drawing .createCellComment (anchor );
5455
5556	 //set the comment text and author 
5657	 comment .setString (factory .createRichTextString ("Found "  + Utility .getCellValue (cell2 )));
57- 	 comment .setAuthor (author );
58+ 	 comment .setAuthor ("SYSTEM" );
5859
5960	 cell1 .setCellComment (comment );
6061	}
0 commit comments