<div dir="ltr"><div>Hello,</div><div><br></div><div>It seems there is another issue with the .Net Core SDK.</div><div><br></div><div>There is a need to set with of the column of a table. There is a function, which sets the width of a table column, listed below. The function is converted from the code, which works with the .Net Framework SDK.</div><div><br></div><div>void SetColumnWidth(XTextTable textTable,int ColNum, short Width)<br>{<br>    Any obj = textTable.query<XPropertySet>().getPropertyValue("TableColumnSeparators");<br>    TableColumnSeparator[] tcs = (TableColumnSeparator[])(obj.Value);<br>    short Delta = 0;<br>    if (tcs != null)<br>    {<br>        if (tcs.Length - 1 >= ColNum)<br>        {<br>            if (ColNum == 0)<br>            {<br>                Delta = (short)(Width - tcs[ColNum].Position);<br>                tcs[ColNum].Position = Width;<br>            }<br>            else<br>            {<br>                Delta = (short)(Width - (tcs[ColNum].Position - tcs[ColNum].Position));<br>                tcs[ColNum].Position = (short)(Width + tcs[ColNum - 1].Position);<br>            }<br>        }<br><br>        Any val = new Any(typeof(com.sun.star.text.TableColumnSeparator[]), tcs);<br>        textTable.query<XPropertySet>().setPropertyValue("TableColumnSeparators", val);<br>    }<br>}</div><div><br></div><div>If the function is called in \sdk\examples\dotnet\WriterDemo\csharp\WriterDemo.cs, like listed below:</div><div><br></div><div>// Get first row<br>XTableRows tableRows = textTable.getRows();<br>Any rowAny = tableRows.query<XIndexAccess>().getByIndex(0);<br><br><b><i>SetColumnWidth(textTable, 1, 200);</i></b><br><br>// Set a different background color for the first row<br>XPropertySet firstRowPropertySet = rowAny.cast<XPropertySet>();<br>firstRowPropertySet.setPropertyValue("BackTransparent", new Any(false));</div><div><br></div><div><br></div><div>It gives an access violation error ("Attempted to read or write protected memory. This is often an indication that other memory is corrupt") on the line</div><div><br></div><div> textTable.query<XPropertySet>().setPropertyValue("TableColumnSeparators", val);</div><div><br></div><div>When I tried to get the columns of the table via the code below (the code is inserted in the 

WriterDemo.cs  example too):</div><div><br></div><div>// Set the table background color<br>XPropertySet tablePropertySet = textTableI.query<XPropertySet>();<br>tablePropertySet.setPropertyValue("BackTransparent", new Any(false));<br>tablePropertySet.setPropertyValue("BackColor", new Any(0xCCCCFF));<br><br><b><i>XTableColumns tableCols = textTable.getColumns();<br>Any colAny = tableCols.query<XIndexAccess>().getByIndex(1);</i></b><br><br>// Get first row<br>XTableRows tableRows = textTable.getRows();<br>Any rowAny = tableRows.query<XIndexAccess>().getByIndex(0);</div><div><br></div><div><br></div><div>However, the   tableCols.query<XIndexAccess>().getByIndex(1) line give another error:</div><div><br></div><div>Exception thrown: 'System.ArgumentException' in net_basetypes.dll<br>An unhandled exception of type 'System.ArgumentException' occurred in net_basetypes.dll<br>Value of Any can only be null if Type is void. Perhaps you want Any.VOID?</div><div><br></div><div><br></div><div>Could you tell me what is a proper way to change the table column width using the .Net Core SDK?</div><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Mar 27, 2025 at 6:28 PM Ilya Sokolov <<a href="mailto:is@rula-tech.com">is@rula-tech.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello</div><div><br></div><div>I am trying to use the .Net Core SDK and  try to run some program, which previously run on .Net Framework.</div><div><br></div><div>There is a strange issue here: there are two properties of a character, CharEscapement and CharEscapementHeight, they are set like</div><div><br></div><div> XText DocText = m_Doc.query<XTextDocument>().getText();<br>   m_TextCursor = DocText.createTextCursor();</div><div><br></div><div>XPropertySet CurObject = m_TextCursor.query<XPropertySet>();</div><div><br></div><div>CurObject.setPropertyValue("CharEscapement", new Any((Int16)0));           <br>                       CurObject.setPropertyValue("CharEscapementHeight", new Any((Byte)100));  </div><div><br></div><div>And the CharEscapement is set successfully, but an : 'Object reference not set to an instance of an object.' exception occurres when the second property is set.</div><div><br></div><div>Could you tell me if there is a known workaround about the issue?</div><div><br></div><div> </div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr">Best Regards,<div>Ilia Sokolov</div><div><br></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr">Best Regards,<div>Ilia Sokolov</div><div><br></div></div></div></div></div></div></div></div></div></div></div>