Move common code blocks to a function.
Move common code blocks to a function.

Change-Id: I1b1aaa0b1dd8cc6e14fbac1981c67a8b63c92c2c

JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core,JurassicWordExcel/core