Unplanned
Last Updated: 08 Aug 2023 09:30 by ADMIN
ADMIN
Tanya
Created on: 16 Mar 2015 14:43
Category: Spreadsheet
Type: Feature Request
19
Spreadsheet: Implement text orientation for cell content
Implement functionality to rotate the text in a cell.
Duplicated Items
10 comments
ADMIN
Martin
Posted on: 22 May 2020 07:10

Hi Luca,

Thank you for the provided additional information.

I logged an item in our backlog to provide only an import/export functionality in order to split the task in smaller and easier to develop tasks: SpreadProcessing: Implement text orientation for cell content import/export from/to XLSX format. You can cast your vote for the implementation as well as subscribe to the task by clicking the Follow button.

Until this feature is developed I could suggest you to customize our code as follows in order import and export the textRotation attribute:

I. In the Spreadsheet.FormatProviders.OpenXml_WPF project

  • AlignmentElement class:

Here you should add a text rotation field and property:

private readonly IntOpenXmlAttribute textRotation;

public int TextRotation
{
	get
	{
		return this.textRotation.Value;
	}
	set
	{
		this.textRotation.Value = value;
	}
}

to include the setting of the filed in the AlignmentElement constructor:

this.textRotation = this.RegisterAttribute(new IntOpenXmlAttribute("textRotation"));

to extend the CopyProertiesFrom() method with the following code:

if (format.TextRotation.HasValue)
{
	this.TextRotation = format.TextRotation.Value;
}

and ApplyAllignment() method with the following: 

if (this.textRotation.HasValue)
{
	format.TextRotation = this.TextRotation;
}
  • FormattingRecord class:

add TextRotation property:

public int? TextRotation {get; set;}

include its setting in the constructor:

this.TextRotation = record.TextRotation;

and extend Equals() and GetHashCode() methods respectively as follows:

// in the EqualsOfT method
TelerikHelper.EqualsOfT(this.TextRotation, other.TextRotation) &&

// in the GetHashCode method
this.TextRotation.GetHashCodeOrZero(),
  • XlsxWorkbookImportContext class:

extend the CreateStyleFromStyleInfo() method in the using block with:

if (formattingRecord.TextRotation.HasValue)
{
	cellStyle.TextRotation = formattingRecord.TextRotation.Value;
}
  • XlsxWorksheetImportContext class:

extend the ImportDirectFormattingInRange() method with:

this.UpdatePropertyInRangeIfNotNull(propertyBag, CellPropertyDefinitions.TextRotationProperty, start, end, directFormatting.TextRotation);
  • XlsxWorkbookExportContext class:

extend the InitStyleFormatting() method with:

if (cellStyle.IsPropertyValueSet(CellPropertyDefinitions.TextRotationProperty))
{
	formattingRecord.TextRotation = cellStyle.TextRotation;
}
  • XlsxWorksheetExportContext class:

add a worksheetEntityToTextRotationCompressedList  field:

private readonly Dictionary<WorksheetEntityBase, ICompressedList<int>> worksheetEntityToTextRotationCompressedList;

and initialize it in the constructor:

this.worksheetEntityToTextRotationCompressedList = new Dictionary<WorksheetEntityBase, ICompressedList<int>>();

then extend the InitDirectFormattingRecords() method with:

this.UpdateProperty(tableEntity,
	this.worksheetEntityToTextRotationCompressedList[tableEntity],
	this.worksheetEntryToDirectFormattingCompressedList[tableEntity],
	(formattingRecord, value) =>
	{
		formattingRecord.TextRotation = value;
		return formattingRecord;
	});

and InitAlignments() method in the foreach statement with:

this.worksheetEntityToTextRotationCompressedList[entity] = entity.PropertyBagBase.GetPropertyValueCollection(CellPropertyDefinitions.TextRotationProperty);

These were the changes in the FormatProvider, now we should make some changes in the SpreadsheetDocuments_WPF project.


II. SpreadsheetDocuments_WPF project

  • CellPropertyDefinitions class:

add this property definition:

public static readonly IPropertyDefinition<int> TextRotationProperty = new PropertyDefinition<int>(TextRotation", true, StylePropertyGroup.Alignment);

and add TextRotationProperty to the AllPropertyDefinitions collection.

  • CellStyle class:

add text rotation field and property:

private readonly StyleProperty<int> textRotation;

public int TextRotation
{
	get
	{
		return this.textRotation.GetValue();
	}
	set
	{
		this.SetStyleProperty(this.textRotation, value);
	}
}

and extends the constructors as follows:

// static CellStyle()
propertyDefinitionToStyleProperty.Add(CellPropertyDefinitions.TextRotationProperty, (style) => { return style.textRotation; });

// internal CellStyle(Workbook workbook, string name, CellStyleCategory category, bool isRemoveable = true, int? builtinId = null)
this.textRotation = new StyleProperty<int>(this, CellPropertyDefinitions.TextRotationProperty);
  • WorksheetPropertyBagBase class:

extend the constructor with:

this.RegisterProperty(CellPropertyDefinitions.TextRotationProperty);

After this setup you should be able to preserve the text orientation after import/export of the document.

Regards,
Martin
Progress Telerik

 

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Luca
Posted on: 18 May 2020 08:56

Hi Martin,

That's right, we write content on the cell which has already text orientation set. After the write all cell style but text orientation is kept. The text orientation is set back to the default. This is the code we use:

internal static void WriteCell(CellSelection cellSelection, string value)
{
if (string.IsNullOrWhiteSpace(value))
{
ClearCell(cellSelection);
}
else
{
// Set the value on the cell while keeping the formatting
cellSelection.SetValue(value);
}
}

The function ClearCell has the same problem

internal static void ClearCell(CellSelection cellSelection)
{
// Clear only the content, keep the formatting
cellSelection.Clear(ClearType.Contents);
}

Although ClearType.Contents is used here, the text orientation is reset here as well.

Thanks,

Luca

ADMIN
Martin
Posted on: 06 May 2020 06:03

Hi Luca,

If I understand you right, you need to keep the imported cell`s text orientation unchanged after export to XLSX format, right? Could you share more information about the specific case?

Looking forward to hearing from you.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Luca
Posted on: 04 May 2020 07:10

Hi Martin,

Thanks for your reply. Since we would really need this feature, is there by any chance a way to implement a workaround? (code customization?)

What we need is to keep the cell style as-is when setting a value on the cell (i.e. if the text orientation is vertical it stays vertical after the value is set). At this moment when setting the value on such a cell, the text orientation is reset to the horizontal position.

Thanks,

Luca

ADMIN
Martin
Posted on: 01 May 2020 07:22

Hi Luca,

I apologize for the inconvenience this missing functionality might be causing you. At this point, I am unable to provide you with a timeframe for releasing this feature as it is currently not scheduled for implementation. Please, make sure you cast your vote for the implementation as well as subscribe to the task by clicking the Follow button so you can receive an update when its status changes.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Luca
Posted on: 30 Apr 2020 15:48

Hi,

Is there a chance this will feature will be implemented anytime soon?

 

Thanks,

Luca

ADMIN
Tanya
Posted on: 08 Oct 2018 19:34
Hello Muhammad,

The task is still not scheduled. This item will be updated accordingly once the team starts working on it, so continue following it to receive email updates.

Regards,
Tanya  
Muhammad Jamil Nawaz
Posted on: 28 Sep 2018 11:45
Any update on this?
ADMIN
Tanya
Posted on: 04 May 2015 08:28
Hi Dewald,

This portal is related with our backlog system and if there is an update on the feature, this item will be updated too. If the feature is already implemented, its status will be "Completed". 

For the time being it is not scheduled and we are not able to give you a specific time frame when it might be available.

Regards, 
Tanya
Dewald
Posted on: 29 Apr 2015 12:18
Has This been done yet ?, We need to use this function of text being vertical