Skip to content

Replies

0
Michael Germann
Michael Germann answered on Aug 1, 2017 3:29 PM

Hi,

   Yes the way you are experiencing it is the way it is intended to work.  We only add the Rows and Cells to the collection when they have a value. So if you are doing a foreach loop through them, you will skip over blank rows and cells. Conversely, when you access the Rows and Cells via the index, if one does not already exist with a RowIndex\ColumnIndex matching that ones given, it will add the Row or Cell to the appropriate collections, assigning it the RowIndex and ColumnIndex values it was used to reference it.

Your snippet seems to have a mix of loop types. You are doing a foreach but then not using theWorksheetCell that it puts out, you are then referencing the Rows\Cells by an index that you don't show how they are initiated or advanced. So it's hard to follow exactly your intent.

Below is a quick snippet that should demonstrate how it works.

Let me know if this helps,


using Infragistics.Documents.Excel;
using System.Diagnostics;

//..

private void Form1_Load(object sender, EventArgs e)
{
 Workbook wb = new Workbook();
 wb.Worksheets.Add("Sheet1");
 var ws = wb.Worksheets[0];

 ws.GetCell("C3").Value = 1;
 OutputWorksheetState(ws);

 ws.Rows[2].Cells[2].Value = 1.1;
 OutputWorksheetState(ws);

 ws.Rows[6].Cells[2].Value = 2;
 OutputWorksheetState(ws);

 ws.GetCell("C7").Value = 2.1;
 OutputWorksheetState(ws);

 ws.GetCell("C33").Value = 3;
 ws.GetCell("C11").Value = 4;
 ws.GetCell("A3").Value = 5;
 ws.GetCell("B7").Value = 6;
 ws.GetCell("H33").Value = 7;
 ws.GetCell("Z11").Value = 8;

 OutputWorksheetState(ws);
}

private void OutputWorksheetState(Worksheet ws)
{
 int eRowIndex = 0;
 int eCellIndex = 0;

 Debug.WriteLine("--------------");
 foreach (WorksheetRow row in ws.Rows)
 {
  eCellIndex = 0;
  foreach (WorksheetCell cell in row.Cells)
  {
   Debug.WriteLine("Cell e[{0},{1}] - a[{2}, {3}] = {4}", eRowIndex, eCellIndex, cell.RowIndex, cell.ColumnIndex, cell.Value);
   eCellIndex++;
  }
  eRowIndex++;
 }
}

0
Michael Germann
Michael Germann answered on Jun 6, 2017 5:56 PM

Hi Kyle,

Thank you for the updated file, I was able to demonstrate the behavior with the sample I provided earlier. It seems that how we are outputting the name with a newline, while Excel recognizes it, it doesn’t appear to be it’s ideal format.

If you change the extension to zip, you can look inside the files to “xl\tables\table1.xml”
You will notice:
INPUT:
<tableColumn id=”1″ name=”table with_x000a_new line” dataDxfId=”0″/>
OUTPUT:
<tableColumn id=”1″ name=”table with&#xD;&#xA;new line” dataDxfId=”2″ />
FIXED BY EXCEL:
<tableColumn id=”1″ name=”table with_x000d__x000a_new line” dataDxfId=”0″/>

If you save it, or manually change the table name such that &#xD;&#xA; is translated to _x000d__x000a_it works fine.

I will log this as a issue with our developers and see if they can address the issue. It should be noted that 2015.1 is outside of our service release support. So if they do have only address this as a fix in our code it will be for those builds currently in service release support. Which at this time is 2016.2 and later.

I will link this forum post to our support system, which you should be able to see that and the development issue through our support system here:
https://ko.infragistics.com/my-account/support-activity

0
Michael Germann
Michael Germann answered on Jun 5, 2017 11:13 PM

Hi Kyle,

I am not able to reproduce the behavior. I’ve tried with 15.1 as well as 16.2. Perhaps I am not following exactly where you are getting the XML issues. Attached is my sample application. Two buttons import, and export. I then open the exported file in Excel, and it works fine. I have commented out the 16.2 specific code that is using the Spreadsheet, importing into that control as well. But it works fine, far as I can tell. What is the full build number for the version that you are using? Perhaps I was not following the exact step that you see the behavior in, is it an exception thrown in either .NET or Excel? Are you looking at a specific XML file inside the XLSX file?

Try it out, and if there is something I am missing in my sample please update it, or elaborate on how to reproduce the issue.
XMLImportIntoWorkbook

0
Michael Germann
Michael Germann answered on Jun 2, 2017 11:57 PM

Hi Kyle,

   While I understand your concern about posting a live Excel file, I am going to need a complete sample file to test against to better understand the issue. Just copy your live file, and replace all the live data with a few rows of dummy data and verify that the dummy file has the same issue. We will need a file to work from.

Thanks,

0
Michael Germann
Michael Germann answered on Apr 10, 2017 5:55 PM

Hi Massimo,

   There are a number of different ways you could possibly achieve the behavior, one of which would be by using a mask. But I am assuming by your intent, you do not care about or do not want to retain the precision. Because while you say the value 12.00 becomes 12.00000 that is not entirely true. 12.00000 is a distinctly different value then 12.00 and 12.00000 is what was stored. If you don't care about the precision, just cut the precision out. Such as in the BeforeEnterEditMode event, truncate the value.
http://stackoverflow.com/questions/1132765/adjusting-decimal-precision-net

If you want to retain the precision, but only if the text hasn't changed that where it can get tricky. I would suggest a IEditorDataFilter, but you could probably more easily do it via caching the original value in BeforeEnterEditMode, then in BeforeExitEditMode, compare the values, if the value coming back equals the truncated cached value, reset the value back to the cached value.

Let me know if that helps,

0
Michael Germann
Michael Germann answered on Mar 3, 2017 5:14 PM

We did implement it as a feature a while ago, so honestly the best way would be to just upgrade. But you could remove the tabstop from the control to keep users from tabbing into it for editing. For clicking into it you can use the following:

private void ultraDateTimeEditor1_MouseDown(object sender, MouseEventArgs e)
{
 UltraDateTimeEditor dtEditor = sender as UltraDateTimeEditor;
 UIElement uiClicked = dtEditor.UIElement.ElementFromPoint(e.Location);
 if (!(uiClicked is DateTimeEditorDropDownButtonUIElement))
  dtEditor.Editor.ExitEditMode(true, true);

}

private void ultraDateTimeEditor1_AfterCloseUp(object sender, EventArgs e)
{
 UltraDateTimeEditor dtEditor = sender as UltraDateTimeEditor;
 dtEditor.Editor.ExitEditMode(true, true);
}

Let me know if that helps,

0
Michael Germann
Michael Germann answered on Mar 1, 2017 8:08 PM

Hi Balaji,

    Yes, it was implemented in version 2013.1, if you set the DropDownStyle property to DropDownList. That should give you the behavior that you are looking for.

Let me know if that helps,