private void LoadEnv() { string envfile; string[] aryLine; m_sExcelSavePath = "c:\\sms"; m_sCrctPath = m_sExePath; envfile = m_sExePath + "\\sden.env"; if (System.IO.File.Exists(envfile) == true) { aryLine = m_libCmn.LoadFileLineSJIS(envfile); m_sExcelSavePath = aryLine[1]; if (aryLine[2] != "") { m_sCrctPath = aryLine[2]; } } envfile = m_sExePath + "\\sdenwait.txt"; if (System.IO.File.Exists(envfile) == true) { aryLine = m_libCmn.LoadFileLineSJIS(envfile); m_nWaitSecond = m_libCmn.StrToInt(aryLine[1]); } }
private void SheetCreate() { int line, clum; String sCellVal; int nNextPageAddLine; // 次のPage格納 int nPageTopLine; int nSetLineCount; int nCount, nSetCount; int idx, max; int setline, setclum; Excel.Worksheet xlsSrcSheet; Excel.Worksheet xlsDstSheet; Excel.Range xlsSrcRng = null; Excel.Range xlsDstRng = null; String[] ary; m_nSetLine = 0; m_nSetClum = 0; m_nSetClum2 = 0; m_nSetLine2 = 0; m_nSetCountClum = 0; m_nSetCountLine = 0; m_nSetCountClum2 = 0; m_nSetCountLine2 = 0; m_sMode = "P"; sCellVal = ""; m_nDstLine = 1; m_nDstClum = 1; m_nSrcLine = 1; m_nSrcSClum = 1; m_nSrcEClum = 1; m_nSrcSLine = 1; m_nSrcELine = 1; m_nSrcPageCount = 1; // Pageに格納できる札の数 m_nSrcAddLine = 1; m_nSkipCount = 1; m_sSumClum = "A"; m_nSumClum = 1; nNextPageAddLine = 1; nPageTopLine = 1; xlsSrcSheet = m_libExcel.GetExcelSheetToName("Sheet1"); if (xlsSrcSheet == null) { return; } xlsDstSheet = m_libExcel.GetDstExcelSheetToName("Sheet1"); if (xlsDstSheet == null) { return; } // /* max = m_nWaitSecond; for (idx = 0; idx < max; idx++) { m_libCmn.DoDispatch(); System.Threading.Thread.Sleep(1000); } // */ String[] aryLine = m_libCmn.LoadFileLineSJIS(m_sSrcDefFile); if (aryLine[0] == "") { for (line = 1, clum = 1; line < 30; line++) { xlsSrcRng = xlsSrcSheet.Cells[line, clum]; sCellVal = xlsSrcRng.Text.ToString(); if (sCellVal != "") { m_nSetClum = 3; m_nSetLine = line; ary = sCellVal.Split(','); if (ary[0] == "S" || ary[0] == "P" || ary[0] == "T" || ary[0] == "p" || ary[0] == "t") { setParameter(ary); break; } } } xlsDstRng = xlsDstSheet.Cells[line, 1]; xlsDstRng.Value2 = ""; } else { ary = aryLine[1].Split(','); m_nSetClum = ABCto123(ary[0]); m_nSetLine = m_libCmn.StrToInt(ary[1]); if (ary.Length >= 4) { m_nSetClum2 = ABCto123(ary[2]); m_nSetLine2 = m_libCmn.StrToInt(ary[3]); } ary = aryLine[2].Split(','); setParameter(ary); if (aryLine.Length >= 4 && aryLine[3] != "") { ary = aryLine[3].Split(','); m_nSetCountClum = ABCto123(ary[0]); m_nSetCountLine = m_libCmn.StrToInt(ary[1]); if (ary.Length >= 4) { m_nSetCountClum2 = ABCto123(ary[2]); m_nSetCountLine2 = m_libCmn.StrToInt(ary[3]); } } } if (m_sMode == "P") { nNextPageAddLine = m_nSrcELine - m_nSrcSLine; nPageTopLine = nPageTopLine + nNextPageAddLine; xlsDstRng = xlsDstSheet.Cells[nPageTopLine, 1]; xlsDstRng.PageBreak = 1; } else if (m_sMode == "T") { nNextPageAddLine = m_nSrcELine - m_nSrcSLine + 1; nPageTopLine = nPageTopLine + nNextPageAddLine; } else if (m_sMode == "p") { nNextPageAddLine = m_nSrcELine - m_nSrcSLine + 1; nPageTopLine = nPageTopLine + nNextPageAddLine; xlsDstRng = xlsDstSheet.Cells[nPageTopLine, 1]; xlsDstRng.PageBreak = 1; } else if (m_sMode == "t") { nNextPageAddLine = m_nSrcELine - m_nSrcSLine + 1; nPageTopLine = nPageTopLine + nNextPageAddLine; } nSetLineCount = 0; for (idx = 0; idx < m_nCrctLineCount; idx++) { ary = m_aryLine[idx].Split(','); if (5 <= ary.Length && ary[0] == "\"未\"") { nSetLineCount++; } } nSetCount = 0; nCount = 0; for (idx = 0; idx < m_nCrctLineCount; idx++) { ary = m_aryLine[idx].Split(','); if (5 <= ary.Length && ary[0] == "\"未\"") { IncProgressBar(); if (m_sMode == "S") { InsertExcelLine(xlsDstSheet, m_nDstLine, m_nDstLine + m_nSkipCount - 1); nEndLine = m_nSrcLine + m_nSkipCount - 1; RowHeightCopy(xlsSrcSheet, m_nSrcLine, nEndLine, xlsDstSheet, m_nDstLine); CopyExcelPage(xlsSrcSheet, m_nSrcLine, m_nSrcSClum, nEndLine, m_nSrcEClum); PasteExcelPage(xlsDstSheet, m_nDstLine, m_nSrcSClum); } xlsDstRng = xlsDstSheet.Cells[m_nDstLine, m_nDstClum]; ary[5] = ary[5].Replace("\"", ""); ary[5] = ary[5].Replace("/", " "); xlsDstRng.Value2 = ary[5].Substring(1); if (m_nSetClum2 != 0 && m_nSetLine2 != 0) { setline = m_nDstLine + m_nSetLine2 - m_nSetLine; setclum = m_nDstClum + m_nSetClum2 - m_nSetClum; xlsDstRng = xlsDstSheet.Cells[setline, setclum]; ary[5] = ary[5].Replace("\"", ""); ary[5] = ary[5].Replace("/", " "); xlsDstRng.Value2 = ary[5].Substring(1); } if (m_nSetCountClum != 0 && m_nSetCountLine != 0) { setline = m_nDstLine + m_nSetCountLine - m_nSetLine; setclum = m_nDstClum + m_nSetCountClum - m_nSetClum; xlsDstRng = xlsDstSheet.Cells[setline, setclum]; ary[4] = ary[4].Replace("\"", ""); xlsDstRng.Value2 = ary[4]; } if (m_nSetCountClum2 != 0 && m_nSetCountLine2 != 0) { setline = m_nDstLine + m_nSetCountLine2 - m_nSetLine; setclum = m_nDstClum + m_nSetCountClum2 - m_nSetClum; xlsDstRng = xlsDstSheet.Cells[setline, setclum]; ary[4] = ary[4].Replace("\"", ""); xlsDstRng.Value2 = ary[4]; } if (m_sMode == "S" || m_sMode == "P" || m_sMode == "D" || m_sMode == "T") { m_nDstLine += m_nSkipCount; } else // "p","t" { m_nDstClum -= m_nSkipCount; } if (m_sMode == "P" || m_sMode == "p" || m_sMode == "D" || m_sMode == "t" || m_sMode == "T" || m_sMode == "t") { nCount++; nSetCount++; if (m_nSrcPageCount <= nCount) { nCount = 0; if (nSetCount < nSetLineCount) { if (m_sMode == "P" || m_sMode == "p") { RowHeightCopy(xlsSrcSheet, m_nSrcSLine, m_nSrcELine, xlsDstSheet, nPageTopLine); CopyExcelPage(xlsSrcSheet, m_nSrcSLine, m_nSrcSClum, m_nSrcELine, m_nSrcEClum); PasteExcelPage(xlsDstSheet, nPageTopLine, m_nSrcSClum); } if (m_sMode == "P" || m_sMode == "T") { m_nDstLine = nPageTopLine + m_nSrcAddLine; } else if (m_sMode == "p" || m_sMode == "t") { m_nDstClum = m_nSetClum; m_nDstLine += (m_nSrcELine - m_nSrcSLine + 1); } nPageTopLine = nPageTopLine + nNextPageAddLine; if (m_sMode == "P" || m_sMode == "p") { xlsDstRng = xlsDstSheet.Cells[nPageTopLine - 1, 1]; xlsDstRng.Value2 = " "; xlsDstRng = xlsDstSheet.Cells[nPageTopLine, m_nSrcEClum + 1]; xlsDstRng.PageBreak = 1; xlsDstRng = xlsDstSheet.Cells[m_nDstLine - 1, 1]; xlsDstRng.Value2 = ""; } } } } } } if (m_sMode == "S") { DeleteExcelLine(xlsDstSheet, m_nDstLine, m_nDstLine + m_nSkipCount - 1); m_nSumLine = m_nDstLine; m_nDstLine = m_nDstLine - 1; xlsDstRng = xlsDstSheet.Cells[m_nSumLine, m_nSumClum]; xlsDstRng.Value2 = "=SUM(" + m_sSumClum + m_nSrcLine + ":" + m_sSumClum + m_nDstLine + ")"; } }