Free Support Forum - aspose.com

Text Formatting from Excel using Aspose Cells

hi,

I've worked with:
Cell cellInput = book.getWorksheets().getRangeByName("CellInput").get(0,0);
Cell cellFinish= book.getWorksheets().getRangeByName("cellFinish").get(0,0);

if (cellInput .characters(0, 0).getFont().isItalic()) {
cellFinish.characters(1, 10).getFont().setBold(true);
}


I apply the shape of the cell called "formatCellule" on another cell called "formatTexte"

but the generation of lost output document format italico I wanted to apply.
and takes the output document formats that are in the cell "formatTexte" without the italic format that does not apply


you can help me ??
please

Hi Dev,


First of all, we have split the existing thread to create a new one on your behalf because you posted on a thread from 2008 whereas the APIs have changed a lot since then. Moreover, your presented scenario seems to be different from the existing one.

Regarding your original concerns, we request you to please post more details, your source spreadsheet, desired output (that you may manually create with Excel) and your current executable code for better understanding of this scenario.

private static final String MAQUETTE_NAME ="testFormItalic.xlsx";
public void testItalicCells() throws Exception {

Workbook book=new Workbook(MAQUETTE_NAME);

Cell celluleDestination = book.getWorksheets().getRangeByName("cell2").get(0,0);
Cell celluleInit = book.getWorksheets().getRangeByName("cell1").get(0,0);

celluleDestination.characters(0, 10).getFont().setColor(celluleInit.characters(0,0).getFont().getColor());
celluleDestination.characters(0, 10).getFont().setSize(celluleInit.characters(0,0).getFont().getSize()); //"apply: important"

if (celluleInit.characters(0, 0).getFont().isBold()) {
celluleDestination.characters(0, 10).getFont().setBold(true);
}
if (celluleInit.characters(0, 0).getFont().isItalic()) {
celluleDestination.characters(0,10).getFont().setItalic(true);
}

book.save("result.xlsx");
}

help me please

Hi,

Thanks for your posting and using Aspose.Cells.

We have run your code which you have provided in the previous post with the latest version and found that generated xlsx file looks good. The cell formatting is ok. I have attached the generated xlsx file and the screenshot showing the output formatting for your reference.

Could you please explain in detail what problem you are facing? You can also provide us screenshot(s) illustrating your issue or you can provide us expected excel file which you can create manually using Microsoft Excel.

Thanks for your cooperation.

it look not good ,


since the original cell has the italic formatting and the result keeps the italic format,
and usually the resutlatdo should not have the italic format from the word “Important”.



and not because it retains the shape of the non italic start cell ??



the result should be like :




Hi,

Thanks for your clarification and using Aspose.Cells.

Please modify your code as the following. Check the red highlighted code. I have attached the output excel file generated by the code for your reference.

Java
Workbook book=new Workbook(“testFormItalic.xlsx”);

Cell celluleDestination = book.getWorksheets().getRangeByName(“cell2”).get(0,0);
Cell celluleInit = book.getWorksheets().getRangeByName(“cell1”).get(0,0);

celluleDestination.characters(0, 10).getFont().setColor(celluleInit.characters(0,0).getFont().getColor());
celluleDestination.characters(0, 10).getFont().setSize(celluleInit.characters(0,0).getFont().getSize()); //"apply: important"

if (celluleInit.characters(0, 0).getFont().isBold()) {
celluleDestination.characters(0, 10).getFont().setBold(true);
}
else
{
celluleDestination.characters(0, 10).getFont().setBold(false);
}

if (celluleInit.characters(0, 0).getFont().isItalic()) {
celluleDestination.characters(0,10).getFont().setItalic(true);
}
else
{
celluleDestination.characters(0,10).getFont().setItalic(false);
}

book.save(“result.xlsx”);



many thanks for your help.

good night.