Cell IndentLevel to left indent in inches

Hello.

We are required to render the table in MS Word as it is in MS Excel.
However, from Aspose Cells we are getting only indent level (as it is in MS Excel).

There is a duplicate topic for this:

However, this topic does not have a proper conclusion (~1.3 point to inches is ~0.01) and is pretty old (5 years old).

There is another duplicate for this:

I think he asked the same question, but response was more about customizing the indentation rather than knowing exact value of single IndenLevel in inches.

What is interesting is that copying from Excel to Word the table indent converts to first line 1 ch.
But there is no explanation what formula to use to get from 1 ch to inches (at certain websites ch = (px-5)/7 is suggested, other websites plainly converts 1 ch to 0.08(3) inches).

How to convert Indent Level (from Aspose Cells) to Left Indent (in Aspose Words) properly?
Is this number of spaces * 3 formula (in normal font) still applicable?

@deivydasr,

Thanks for providing us details.

How do you transform MS Excel contents to Word document? I guess you might have written your own code or some sort of utility (code) to convert/copy Excel spreadsheet formatted data/range to Word document via Aspose.Cells APIs and Aspose.Words APIs. I am afraid results might not be always reliable. Please note, both Aspose.Cells and Aspose.Words are different and diverse APIs (even MS Word and MS Excel are diverse applications) having different architectures, so you cannot always parse objects’ data accurately b/w the APIs. A general and better approach might be that you may try is:

  1. Convert your Excel range/data or spreadsheet into PDF using Aspose.Cells
  2. Now convert the output PDF into Word document using Aspose.PDF.
    Please see the following documentation articles for your reference:
    Convert Excel Workbook to PDF
    Convert PDF to DOC and DOCX

Hope, this helps a bit.

Thank you for the suggestion, @Amjad_Sahi .

Yes, separate code is written for conversion. I am fully aware of diverse applications, but, in my opinion, it could be transferred pretty identically.
Your provided method for converting excel data to docx format is great, but it does not suit right now.

I would like to get just answers to my asked questions, nothing more. Thank you!

@deivydasr,

I guess these things are complex to be sorted out accurately. Anyways, we will check if we could come up with our findings.

By the way, Aspose.Words team have written a utility to convert XLS file to MS Word document. I would recommend you to try it if it suits your needs.
TestApp.zip (68.0 KB)

Thank you, I will be waiting for these findings.

@deivydasr,

Yes, in MS Excel, the indent is spaces * 3 formula (in normal font) still there. We have evaluated your issue in details. If you want, we can provide the size in unit of Pixels for indent. Let us know if it suits your needs, so we could log a ticket for it upon your confirmation.

Thank your for this information! Few questions:

  • What is normal font?
  • How to get normal font in Aspose Cells?

Size in unit of pixels would be amazing!

@deivydasr,

We will get back to you soon for your queries.

@deivydasr,

In the mean time, we have logged a ticket for into our database to support your needs. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46967 – Provide indent size in unit of pixels

Thank you, @Amjad_Sahi. Waiting for the answer.

@deivydasr,

We are working over your issue and hopefully we will provide you the fixed version in 2-4 days or so.

Also, for your queries, you may give it a try:
e.g
Sample code:

[Test]
public void CellsNet46967()
{
Workbook workbook = new Workbook();
Assert.AreEqual(9.75,CellsHelper.GetTextWidth(" ", workbook.DefaultStyle.Font, 1));
}

@deivydasr,

Please try our latest version/fix: Aspose.Cells for .NET v19.10.3 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.10.3 For .Net2_AuthenticodeSigned.Zip (5.0 MB)
Aspose.Cells19.10.3 For .Net4.0.Zip (5.0 MB)

@Amjad_Sahi
Wow, that was fast!
One small issue - we are using Aspose.Cells for Java.
Can this fix be applied to it too?

@deivydasr,

You should have mentioned explicitly that you are using Aspose.Cells for Java. Anyways, no worries, all the enhancements and features included in .NET version are also included in Java and vice versa. Aspose APIs for Java have same codebase as they are ported from .NET version of the API.

Please wait as we will also implement this feature in Java version as well.

Keep in touch.

@Amjad_Sahi

Is Java version still not available?

@deivydasr,

It is available now.
Please try our latest version/fix: Aspose.Cells for Java v19.10.4 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose_Cells_Java_v19.10.4.zip (6.6 MB)

The issues you have found earlier (filed as CELLSNET-46967) have been fixed in Aspose.Cells for .NET v19.11. This message was posted using Bugs notification tool by Amjad_Sahi

@Amjad_Sahi,

Could you write which function provides indent size in pixels?

@deivydasr,
Could you please give a try to the following sample code and share the feedback.

// For complete examples and data files, please go to GitHub - aspose-cells/Aspose.Cells-for-Java: Aspose.Cells for Java examples, plugins and showcases

// The path to the output directory.
String sourceDir = Utils.Get_SourceDirectory();
Workbook workbook = new Workbook(sourceDir + "GetTextWidthSample.xlsx");
System.out.println("Text width: " + CellsHelper.getTextWidth(workbook.getWorksheets().get(0).getCells().get("A1").getStringValue(), workbook.getDefaultStyle().getFont(), 1));

You may follow the following article for more details:
Get Text Width of Cell Value

@ahsaniqbalsidiqui

Thank you for your quick and informative reply!

I want to be 100% clear: I have a text Hello World! with indentLevel = 4. How to know exactly the indentation size? If I will use this getTextWidth, I will get the whole cell text width, but I still would not know what is the exact size of the indentation.

Thanks in advance.