Cell note in jxls template is not deleted - spring

PoiTransformer transformer = PoiTransformer.createTransformer(is, os);
AreaBuilder areaBuilder = new XlsCommentAreaBuilder(transformer, false);
List<Area> xlsAreaList = areaBuilder.build();
int curSheetSize = 3;
for(int i = 1; i < 1; i++) {
Area mainArea = xlsAreaList.get(i);
Area loopArea = mainArea.getCommandDataList().get(0).getCommand().getAreaList().get(0);
loopArea.addAreaListener(new JxlsAreaListener(transformer, i));
switch (i) {
case 1 :
mainArea.applyAt(new CellRef("KOR!A1"), context);
break;
case 2 :
mainArea.applyAt(new CellRef("JPN!A1"), context);
break;
case 3 :
mainArea.applyAt(new CellRef("FRA!A1"), context);
break;
case 4 :
mainArea.applyAt(new CellRef("AUS!A1"), context);
break;
case 5 :
mainArea.applyAt(new CellRef("UK!A1"), context);
break;
case 6 :
mainArea.applyAt(new CellRef("CAN!A1"), context);
break;
case 7 :
mainArea.applyAt(new CellRef("MEX!A1"), context);
break;
}
mainArea.processFormulas();
}
transformer.write();
is.close();
os.close();
I hope the memo is deleted in the Excel file made from template. please.
is templete
enter image description here
is Files created from templates
enter image description here

Related

[eyeshot]How can I add a new Viewport into a viewer

what is the best way to add a new viewport into the viewer with the same drawing?
Regards Jürgen
You can check the Custom ViewportLayout source code sample.
Here is the code extracted from the above sample
private static void InitializeViewportsByLayoutType(Design design, viewportLayoutType layout)
{
int viewportsNumber;
switch (layout)
{
case viewportLayoutType.SingleViewport:
viewportsNumber = 1;
break;
case viewportLayoutType.TwoViewportsVertical:
case viewportLayoutType.TwoViewportsHorizontal:
viewportsNumber = 2;
break;
case viewportLayoutType.ThreeViewportsWithOneOnBottom:
case viewportLayoutType.ThreeViewportsWithOneOnLeft:
case viewportLayoutType.ThreeViewportsWithOneOnRight:
case viewportLayoutType.ThreeViewportsWithOneOnTop:
viewportsNumber = 3;
break;
case viewportLayoutType.FourViewports:
case viewportLayoutType.Stacked:
viewportsNumber = 4;
break;
default:
viewportsNumber = 1;
break;
}
if (design.Viewports.Count > viewportsNumber)
{
while (design.Viewports.Count > viewportsNumber)
design.Viewports.RemoveAt(design.Viewports.Count - 1);
}
else
{
while (design.Viewports.Count < viewportsNumber)
{
design.Viewports.Add((Viewport)design.Viewports[0].Clone());
}
}
// When changing the LayoutMode, the UpdateViewportsSizeAndLocation() method is called as well.
design.LayoutMode = layout;
}

Got Null result from Oracle even though the real result are decimal value

I am new to Oracle in Visual Studio,
I used Oracle.ManagedDataAccess as my reference,
The case is whenever I tried to retrieve decimal value from arithmetic in Oracle query, Its always return null
e.g
SELECT 26/3 FROM DUAL < ---- This code return null in my visual studio but has a value in TOAD.
Did I do it wrong ?
Here is my code to retrieve the value
List<object[]> result = new List<object[]>();
OracleDataReader data;
string constr = ConfigurationManager.ConnectionStrings["OraConnection"].ConnectionString;
using (OracleConnection con = new OracleConnection(constr))
{
string query = QueryString;
using (OracleCommand cmd = new OracleCommand(query))
{
cmd.Connection = con;
con.Open();
data = cmd.ExecuteReader();
try
{
if (data.HasRows)
{
while (data.Read())
{
object[] itemData = new object[data.FieldCount];
//Dictionary<string, string> itemData = new Dictionary<string, string>();
for (int i = 0; i < data.FieldCount; i++)
{
Type type = data.GetValue(i).GetType();
if (typeof(string) == type)
{
itemData[i] = data.GetString(i);
}
if (typeof(DateTime) == type)
{
itemData[i] = data.GetDateTime(i);
}
if (typeof(int) == type)
{
itemData[i] = data.GetInt32(i);
}
if (typeof(decimal) == type)
{
itemData[i] = data.GetDecimal(i);
}
if (typeof(bool) == type)
{
itemData[i] = data.GetBoolean(i);
}
if (typeof(TimeSpan) == type)
{
itemData[i] = data.GetTimeSpan(i);
}
if (typeof(Single) == type)
{
itemData[i] = Convert.ToDecimal(data.GetOracleDecimal(i).ToString());
}
}
result.Add(itemData);
}
}
else
{
Console.WriteLine("Rows not found.");
}
}
finally
{
data.Close();
}
con.Close();
}
}
return result;
UPDATED : It got null just for division which has decimal value. Addition, Substraction, multiplication has no issue
It seems your data type doesn't match any of your if expressions. As there is no default branch, itemData[i] remains null. I suggest something like the following to find the gap:
for (int i = 0; i < data.FieldCount; i++)
{
Type type = data.GetValue(i).GetType();
switch(type)
{
case typeof(string):
itemData[i] = data.GetString(i);
break;
case typeof(DateTime):
itemData[i] = data.GetDateTime(i);
break;
case typeof(int):
itemData[i] = data.GetInt32(i);
break;
case typeof(decimal):
itemData[i] = data.GetDecimal(i);
break;
case typeof(bool):
itemData[i] = data.GetBoolean(i);
break;
case typeof(TimeSpan):
itemData[i] = data.GetTimeSpan(i);
break;
case typeof(Single):
itemData[i] = Convert.ToDecimal(data.GetOracleDecimal(i).ToString());
break;
default:
MessageBox.Show("Unknown type " + type.Name);
break;
}
}
So, I got an advice to edit the oracle query
From (e.g.)
SELECT 26/7 FROM DUAL
TO
SELECT TO_CHAR(26/7) FROM DUAL
And yes it works
But still, I don't know why

How to change height of edit box associated with CMFCToolbarEditBoxButton

I would like to decrease the height of the edit box associated with a CMFCToolbarEditBoxButton on a CMFCToolBar.
I have been able to change successfully the height of a combo box associated with CMFCToolbarComboBoxButton by changing the font size after the ReplaceButton step in OnToolbarReset.
This approach doesn't work for CMFCToolbarEditBoxButton. (see CGuiEditBox section in the following code.)
The first code is from OnToolbarSet. I assign a font to the edit box. I even tried making the size of the font very small. It had no effect.
Next I tried to change the rectangle associated with the edit box in the toolbar's AdjustLocations method. That approach also was unsuccessful.
LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM)
{
UINT uiToolBarId = (UINT)wp;
switch (uiToolBarId)
{
case IDR_TOPTOOLBAR_REG:
{
CZoomCombo ZoomCombo;
ZoomCombo.EnableWindow(TRUE);
ZoomCombo.SetDropDownHeight(300);
ZoomCombo.SetCenterVert(TRUE);
ZoomCombo.AddItem(_T(".5x"));
ZoomCombo.AddItem(_T("1x"));
ZoomCombo.AddItem(_T("2x"));
ZoomCombo.AddItem(_T("3x"));
ZoomCombo.AddItem(_T("4x"));
ZoomCombo.AddItem(_T("5x"));
ZoomCombo.AddItem(_T("6x"));
ZoomCombo.AddItem(_T("7x"));
ZoomCombo.AddItem(_T("8x"));
ZoomCombo.AddItem(_T("9x"));
ZoomCombo.AddItem(_T("10x"));
m_wndTopToolBar.ReplaceButton(IDC_ZOOMCOMBO_DUMMY, ZoomCombo);
do
{
CMFCToolBarButton* pButton = NULL;
int nZoomIndex = m_wndTopToolBar.CommandToIndex(IDC_ZOOMCOMBO);
if (nZoomIndex == -1)
break;
pButton = m_wndTopToolBar.GetButton(nZoomIndex);
if (pButton == NULL)
break;
ASSERT(pButton->IsKindOf(RUNTIME_CLASS(CMFCToolBarComboBoxButton)));
CMFCToolBarComboBoxButton* pComboButton = (CMFCToolBarComboBoxButton*)pButton;
CComboBox* pCbo = pComboButton->GetComboBox();
CEdit* pEdit = pComboButton->GetEditCtrl();
if (pCbo == NULL || pEdit == NULL)
break;
pCbo->SetFont(&m_ToolBarBtnFont);
pEdit->SetFont(&m_ToolBarBtnFont);
m_wndTopToolBar.InvalidateButton(nZoomIndex);
int nSel = GetZoomComboIndex(m_Zoom);
if (nSel >= 0)
{
pCbo->SetCurSel(nSel);
CString str;
pCbo->GetWindowText(str);
pComboButton->SetText(str);
}
} while (false);
//
CGuiEditBox GuiEditBox;
GuiEditBox.EnableWindow(TRUE);
m_wndTopToolBar.ReplaceButton(IDC_GUIEDITBOX_DUMMY, GuiEditBox);
do
{
CMFCToolBarButton* pButton = NULL;
int nGuiIndex = m_wndTopToolBar.CommandToIndex(IDC_GUIEDITBOX);
if (nGuiIndex == -1)
break;
pButton = m_wndTopToolBar.GetButton(nGuiIndex);
if (pButton == NULL)
break;
ASSERT(pButton->IsKindOf(RUNTIME_CLASS(CMFCToolBarEditBoxButton)));
CMFCToolBarEditBoxButton* pEditBoxButton = (CMFCToolBarEditBoxButton*)pButton;
CEdit* pEdit = pEditBoxButton->GetEditBox();
if (pEdit == NULL)
break;
pEdit->SetFont(&m_ToolBarBtnFont); // height of this font is much less than default
//CFont* pFont = pEdit->GetFont();
//LOGFONT lf;
//pFont->GetLogFont(&lf); // confirmed that font has been changed
m_wndTopToolBar.InvalidateButton(nGuiIndex);
} while (false);
}
break;
}
return 0;
}
//
void CMFCToolBarEx::AdjustLocations()
{
CMFCToolBar::AdjustLocations();
if (GetSafeHwnd())
{
CMFCToolBarButton* pButton = NULL;
int nGuiIndex = CommandToIndex(IDC_GUIEDITBOX);
if (nGuiIndex != -1)
{
pButton = GetButton(nGuiIndex);
if (pButton)
{
ASSERT(pButton->IsKindOf(RUNTIME_CLASS(CMFCToolBarEditBoxButton)));
CMFCToolBarEditBoxButton* pEditBoxButton = (CMFCToolBarEditBoxButton*)pButton;
CEdit* pEdit = pEditBoxButton->GetEditBox();
if (pEdit != NULL)
{
CRect rPos;
pEdit->GetRect(&rPos);
rPos.DeflateRect(0, 4);
pEdit->SetRect(rPos);
}
}
}
}
}
I investigated the source code for afxtoolbareditboxbutton.cpp and saw that the height of the edit box is being set in the OnMove method by the following line
int cy = GetGlobalData()->GetTextHeight();
I changed that line in a subclass of CMFCToolBarEditBoxButton to resolve my problem.

Update a single column to EF 6.0 using LINQ lambda ? MVC4

I want to save the data when i edit something in my data-table on enter .
On enter control goes to method in controller where actual update performs .
My code till this point:
public string UpdateData(int id, string value, int? rowId, int? columnPosition, int? columnId, string columnName)
{
var Leadsinfo = ser_obj1.Lead_List();
if (columnPosition == 0 && Leadsinfo.Any(c => c.Contact_Name.ToLower().Equals(value.ToLower())))
return "Lead with a name '" + value + "' already exists";
var Lead = Leadsinfo.FirstOrDefault(c => c.Lead_Id == id);
if (Lead == null)
{
return "Lead with an id = " + id + " does not exists";
}
switch (columnPosition)
{
case 0:
Lead.Contact_Name = value;
iWise_NeoEntities ooo = new iWise_NeoEntities();
break;
case 1:
Lead.Contact_Address = value;
break;
case 2:
Lead.Lead_Source = value;
break;
case 3:
Lead.Domain = value;
break;
default:
break;
}
return value;
}
In the above code i mentioned i need to write logic where it should save to DB upon any column editing . using lambda linq is easy i guess , But i dont know even how to start ?
Do i need to write save under each case?
You can create update method in database:
public void UpdateLead(Lead model)
{
var entity = db.Set<Lead>().Find(model.Id);
db.Entry<Lead>(entity).CurrentValues.SetValues(model);
db.SaveChanges();
}
And use it where you need:
switch (columnPosition)
{
case 0: Lead.Contact_Name = value; break;
case 1: Lead.Contact_Address = value; break;
case 2: Lead.Lead_Source = value; break;
case 3: Lead.Domain = value; break;
default: break;
}
iWise_NeoEntities ooo = new iWise_NeoEntities();
ooo.UpdateLead(Lead);

NPOI does not evaluate 3d formula

I'm using NPOI to read data from Excel 2003 files. These files contains formulas like this SUM('1:2'!$C$17). NPOI recognized such formulas like SUM('1'!$C$17) (w/o sheet 2) and evaluate invalid result.
I'm using a regular code from NPOI examples, like
foreach (var row in docRows)
{
sb.AppendFormat("{0}\t", SomeCode);
rowCounter += 1;
sb.AppendFormat("{0}\t", rowCounter);
foreach (var col in docColumns)
{
ICell cell = sheet.GetRow(row).GetCell(col);
sb.AppendFormat("{0}\t", GetExcelCellValue(cell));
}
sb.AppendLine();
}
private string GetExcelCellValue(ICell cell)
{
string cellValue = string.Empty;
IFormulaEvaluator evaluator = _hssfworkbook.GetCreationHelper().CreateFormulaEvaluator();
evaluator.Evaluate(cell);
switch (evaluator.EvaluateInCell(cell).CellType)
{
case CellType.BLANK:
cellValue = string.Empty;
break;
case CellType.BOOLEAN:
cellValue = string.Empty;
break;
case CellType.NUMERIC:
cellValue = Convert.ToString(cell.NumericCellValue); //This is a trick to get the correct value of the cell. NumericCellValue will return a numeric value no matter the cell value is a date or a number.
break;
case CellType.STRING:
throw new ArgumentNullException();
cellValue = cell.StringCellValue;
break;
case CellType.ERROR:
cellValue = string.Empty;
break;
case CellType.FORMULA:
break;
}
return cellValue;
}
I have just encountered this problem and I solved it by
switch (cell.CellType)
{
case CellType.Blank:
cellValue = "";
break;
case CellType.Boolean:
cellValue = cell.BooleanCellValue.ToString();
break;
case CellType.Formula:
cellValue = cell.NumericCellValue.ToString();
break;
case CellType.Numeric:
cellValue = cell.NumericCellValue.ToString();
break;
case CellType.String:
cellValue = cell.StringCellValue;
break;
}

Resources