String length limitations

50 views
Skip to first unread message

hugh.a...@gmail.com

unread,
Jul 17, 2023, 10:28:56 AM7/17/23
to Excel-DNA
I have found that the limit of characters in a cell is 32,767 unicode characters.

I have two functions, one that potentially returns a very long string, and a second that performs some processing on it.

I tried to work around the limit by nesting one function inside the other so that the cell was never written to, but the problem persisted (cutting the string off at 32,767 chars).

As such it seems like the character limit is not just on cell contents, but on the size of string that can be handled by Excel UDFs.

Is there any other workaround to this, apart from changing the behaviour of my functions to use handles against a stored version of the string instead?

Govert van Drimmelen

unread,
Jul 17, 2023, 10:39:00 AM7/17/23
to exce...@googlegroups.com

Hi Hugh,

 

> Is there any other workaround to this, apart from changing the behaviour of my functions to use handles against a stored version of the string instead?

 

I don’t think so – this is the Excel limit for strings in the C API (which Excel-DNA uses).

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/f3091803-80f6-40ad-ab7c-b3697476e7f8n%40googlegroups.com.

Kedar Kulkarni

unread,
Jul 17, 2023, 2:54:30 PM7/17/23
to Excel-DNA
This is the link for the Excel specifications and limits - https://support.microsoft.com/en-gb/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3

It clearly mentions 

Total number of characters that a cell can contain  - 32,767 characters

This limit is for Excel's own functions as well ie =REPT("-", 32767) returns a value but =REPT("-", 32768) returns a #Value. 

So no workaround for the same except using cached memory value. 

We had a similar issue to store comma-separated keys for a query - so we used to create a dictionary of values with a GUID key that is created from the md5 hash of the formula parameters. So same formula entered/calculated again - would get you the cached version to avoid costly recomputation. One can not anyways see what's in the cell if the cell contains more than 1024 chars or something (I am unsure of that exact limit). 

thanks

hugh.a...@gmail.com

unread,
Jul 18, 2023, 7:11:38 AM7/18/23
to Excel-DNA
Thanks for the feedback, we will find a way to workaround it.
Reply all
Reply to author
Forward
0 new messages