We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Retrieve xls row style and apply it to new PDF

Hi,

We have a requirement like retrieve xls row style & content and apply it to new PDF while creating.

Thanks,

Naresh.

Hi,


Well, you may use Cell.GetStyle() method to get a style object and brows the properties of the style object to retrieve/check different formatting attributes. To get the content of the cell, you may use Cell.StringValue, Cell.Value and other methods.

Also, to create PDF files by Aspose.Cells would be based on Excel workbook. For example, you may create a new Workbook, fill data, apply style/formatting, then finally save to PDF format. This is the process.

See some topics in the section/sub-section that may help you to apply formattings to cells/range of cells or insert data into cells etc.:
http://www.aspose.com/docs/display/cellsnet/Retrieving+Data+from+Cells
http://www.aspose.com/docs/display/cellsnet/Importing+Data+to+Worksheets
http://www.aspose.com/docs/display/cellsnet/Working+with+Data+Formatting

Hi ,

thanks for response.

I am capturing the excel style using Aspose.cells and I am creating the pdf using Aspose.pdf. Please find below code what I am writing into pdf.

FileStream fstream = new FileStream(strFilename, FileMode.Open);
Workbook workbook = new Workbook(fstream);
Worksheet worksheet = workbook.Worksheets[2];
Aspose.Cells.Row row = worksheet.Cells.Rows[0];


Aspose.Cells.Cells cell = worksheet.Cells;
Range myrange1 = cell.CreateRange(0, 0, 47, 9);
myrange1.Name = “rangewrokrbookScope”;

string text3;
text3 = string.Empty;

text3 = text3 + ((object[,])(myrange1.Value))[0, 0].ToString();

Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(text3);

sec1.Paragraphs.Add(text);

string Row2; Row2 = string.Empty;
for (int i = 1; i < 6; i++)
{
Row2 = ((object[,])(myrange1.Value))[i, 0].ToString();
Style style = worksheet.Cells.Rows[i].Style;
Aspose.Pdf.Generator.Text RowText = new Aspose.Pdf.Generator.Text(Row2);
sec1.Paragraphs.Add(RowText);
RowText = null;
Row2 = string.Empty;
}

pdf1.Save(strOutputFile);

now I need to apply the exact styles of excel row to pdf.

Please guide how can I achieve this.

Thanks,

Naresh

Hi,


Well, if you need to convert Excel file to PDF, please use only Aspose.Cells product and use the direct approach to do that. All MS Excel row/cells styles/formattings would be retained in the generated PDF, see the document for your reference:
http://www.aspose.com/docs/display/cellsnet/Converting+to+PDF+Files

Moreover, please note since both Aspose.Cells and Aspose.Pdf are different components and have their own architectures and data models used for different file formats etc., so type casting of the objects (b/w components) is not possible.

Thank you.


Thanks for quick response.

Yes..I can use direct conversion method in Aspose.cell but we have actual requirement is need to convert the excel to Tagged PDF.So Aspose.cells/Asopse.pdf is not able support directly due to this I am capturing the data from Excel and writing into PDF document while creating.

Is there any way to convert Excel to Tagged pdf using Aspose.cells.

Thanks,

Naresh

Hi,


If you got an issue regarding retrieving XLS row style for Aspose.Cells, please let us know with details, separate the issue regarding Aspose.Cells product only and create a separate sample console application (you may zip it prior attaching here) with template Excel file. We will check it soon. Also, we can only help you regarding any issue (if found) for Aspose.Cells.

And, regarding tagged PDF file, i think Aspose.Pdf team is already on it as per your other thread:
<a href="https://forum.aspose.com/t/84451


Thank you.