| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848 |
- using System;
- using System.ComponentModel;
- using System.IO;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Text;
- using Microsoft.VisualBasic;
- using Microsoft.VisualBasic.CompilerServices;
- namespace Dongke.IBOSS.PRD.Framework.Controls
- {
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class newDGVtoExcel
- {
- public enum ValueTypes
- {
- xlsInteger,
- xlsNumber,
- xlsText
- }
- public enum CellAlignment
- {
- xlsGeneralAlign = 0,
- xlsLeftAlign = 1,
- xlsCentreAlign = 2,
- xlsRightAlign = 3,
- xlsFillCell = 4,
- xlsLeftBorder = 8,
- xlsRightBorder = 16,
- xlsTopBorder = 32,
- xlsBottomBorder = 64,
- xlsShaded = 128
- }
- public enum CellFont
- {
- xlsFont0 = 0,
- xlsFont1 = 64,
- xlsFont2 = 128,
- xlsFont3 = 192
- }
- public enum CellHiddenLocked
- {
- xlsNormal = 0,
- xlsLocked = 0x40,
- xlsHidden = 0x80
- }
- public enum MarginTypes
- {
- xlsLeftMargin = 38,
- xlsRightMargin,
- xlsTopMargin,
- xlsBottomMargin
- }
- public enum FontFormatting
- {
- xlsNoFormat = 0,
- xlsBold = 1,
- xlsItalic = 2,
- xlsUnderline = 4,
- xlsStrikeout = 8
- }
- private struct FONT_RECORD
- {
- public short opcode;
- public short length;
- public short FontHeight;
- public byte FontAttributes1;
- public byte FontAttributes2;
- public byte FontNameLength;
- }
- private struct PASSWORD_RECORD
- {
- public short opcode;
- public short length;
- }
- private struct HEADER_FOOTER_RECORD
- {
- public short opcode;
- public short length;
- public byte TextLength;
- }
- private struct PROTECT_SPREADSHEET_RECORD
- {
- public short opcode;
- public short length;
- public short Protect;
- }
- private struct FORMAT_COUNT_RECORD
- {
- public short opcode;
- public short length;
- public short Count;
- }
- private struct FORMAT_RECORD
- {
- public short opcode;
- public short length;
- public byte FormatLenght;
- }
- private struct COLWIDTH_RECORD
- {
- public short opcode;
- public short length;
- public byte col1;
- public byte col2;
- public short ColumnWidth;
- }
- private struct BEG_FILE_RECORD
- {
- public short opcode;
- public short length;
- public short version;
- public short ftype;
- }
- private struct END_FILE_RECORD
- {
- public short opcode;
- public short length;
- }
- private struct PRINT_GRIDLINES_RECORD
- {
- public short opcode;
- public short length;
- public short PrintFlag;
- }
- private struct tInteger
- {
- public short opcode;
- public short length;
- public short row;
- public short col;
- public byte rgbAttr1;
- public byte rgbAttr2;
- public byte rgbAttr3;
- public short intValue;
- }
- private struct tNumber
- {
- public short opcode;
- public short length;
- public short row;
- public short col;
- public byte rgbAttr1;
- public byte rgbAttr2;
- public byte rgbAttr3;
- public double NumberValue;
- }
- private struct tText
- {
- public short opcode;
- public short length;
- public short row;
- public short col;
- public byte rgbAttr1;
- public byte rgbAttr2;
- public byte rgbAttr3;
- public byte TextLength;
- }
- private struct MARGIN_RECORD_LAYOUT
- {
- public short opcode;
- public short length;
- public double MarginValue;
- }
- private struct HPAGE_BREAK_RECORD
- {
- public short opcode;
- public short length;
- public short NumPageBreaks;
- }
- private struct DEF_ROWHEIGHT_RECORD
- {
- public int opcode;
- public int length;
- public int RowHeight;
- }
- private struct ROW_HEIGHT_RECORD
- {
- public int opcode;
- public int length;
- public int RowNumber;
- public int FirstColumn;
- public int LastColumn;
- public int RowHeight;
- public int @internal;
- public byte DefaultAttributes;
- public int FileOffset;
- public byte rgbAttr1;
- public byte rgbAttr2;
- public byte rgbAttr3;
- }
- private int m_shtFileNumber;
- private BEG_FILE_RECORD m_udtBEG_FILE_MARKER;
- private END_FILE_RECORD m_udtEND_FILE_MARKER;
- private HPAGE_BREAK_RECORD m_udtHORIZ_PAGE_BREAK;
- private short[] m_shtHorizPageBreakRows;
- private short m_shtNumHorizPageBreaks;
- public bool PrintGridLines
- {
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- set
- {
- try
- {
- PRINT_GRIDLINES_RECORD pRINT_GRIDLINES_RECORD = default(PRINT_GRIDLINES_RECORD);
- pRINT_GRIDLINES_RECORD.opcode = 43;
- pRINT_GRIDLINES_RECORD.length = 2;
- if (value)
- {
- pRINT_GRIDLINES_RECORD.PrintFlag = 1;
- }
- else
- {
- pRINT_GRIDLINES_RECORD.PrintFlag = 0;
- }
- FileSystem.FilePut(m_shtFileNumber, pRINT_GRIDLINES_RECORD, -1L);
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- ProjectData.ClearProjectError();
- }
- }
- }
- public bool ProtectSpreadsheet
- {
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- set
- {
- try
- {
- PROTECT_SPREADSHEET_RECORD pROTECT_SPREADSHEET_RECORD = default(PROTECT_SPREADSHEET_RECORD);
- pROTECT_SPREADSHEET_RECORD.opcode = 18;
- pROTECT_SPREADSHEET_RECORD.length = 2;
- if (value)
- {
- pROTECT_SPREADSHEET_RECORD.Protect = 1;
- }
- else
- {
- pROTECT_SPREADSHEET_RECORD.Protect = 0;
- }
- FileSystem.FilePut(m_shtFileNumber, pROTECT_SPREADSHEET_RECORD, -1L);
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- ProjectData.ClearProjectError();
- }
- }
- }
- [DllImport("kernel32", CharSet = CharSet.Ansi, EntryPoint = "RtlMoveMemory", ExactSpelling = true, SetLastError = true)]
- private static extern void CopyMemory([MarshalAs(UnmanagedType.AnsiBStr)] ref string lpvDest, ref short lpvSource, int cbCopy);
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int CreateFile(string strFileName)
- {
- int result;
- try
- {
- if (File.Exists(strFileName))
- {
- File.SetAttributes(strFileName, FileAttributes.Normal);
- File.Delete(strFileName);
- }
- m_shtFileNumber = FileSystem.FreeFile();
- FileSystem.FileOpen(m_shtFileNumber, strFileName, OpenMode.Binary);
- FileSystem.FilePut(m_shtFileNumber, m_udtBEG_FILE_MARKER, -1L);
- WriteDefaultFormats();
- m_shtHorizPageBreakRows = new short[1];
- m_shtNumHorizPageBreaks = 0;
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int CloseFile()
- {
- int result;
- try
- {
- if (m_shtFileNumber > 0)
- {
- if (m_shtNumHorizPageBreaks > 0)
- {
- int num = Information.UBound(m_shtHorizPageBreakRows);
- int num2 = Information.LBound(m_shtHorizPageBreakRows);
- short num6;
- short num7;
- checked
- {
- for (int i = num; i >= num2; i += -1)
- {
- int num3 = Information.LBound(m_shtHorizPageBreakRows) + 1;
- int num4 = i;
- for (int j = num3; j <= num4; j++)
- {
- if (m_shtHorizPageBreakRows[j - 1] > m_shtHorizPageBreakRows[j])
- {
- int num5 = m_shtHorizPageBreakRows[j - 1];
- m_shtHorizPageBreakRows[j - 1] = m_shtHorizPageBreakRows[j];
- m_shtHorizPageBreakRows[j] = (short)num5;
- }
- }
- }
- m_udtHORIZ_PAGE_BREAK.opcode = 27;
- m_udtHORIZ_PAGE_BREAK.length = Convert.ToSByte(2 + m_shtNumHorizPageBreaks * 2);
- m_udtHORIZ_PAGE_BREAK.NumPageBreaks = m_shtNumHorizPageBreaks;
- FileSystem.FilePut(m_shtFileNumber, m_udtHORIZ_PAGE_BREAK, -1L);
- num6 = 1;
- num7 = (short)Information.UBound(m_shtHorizPageBreakRows);
- }
- for (short num8 = num6; num8 <= num7; num8++)
- {
- FileSystem.FilePut(m_shtFileNumber, MKI(ref m_shtHorizPageBreakRows[num8]), -1L);
- }
- }
- FileSystem.FilePut(m_shtFileNumber, m_udtEND_FILE_MARKER, -1L);
- FileSystem.FileClose(m_shtFileNumber);
- result = 0;
- }
- else
- {
- result = -1;
- }
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- private void Init()
- {
- m_udtBEG_FILE_MARKER.opcode = 9;
- m_udtBEG_FILE_MARKER.length = 4;
- m_udtBEG_FILE_MARKER.version = 2;
- m_udtBEG_FILE_MARKER.ftype = 10;
- m_udtEND_FILE_MARKER.opcode = 10;
- }
- public newDGVtoExcel()
- {
- Init();
- }
- public int InsertHorizPageBreak(ref int lrow)
- {
- checked
- {
- int result;
- try
- {
- short num = ((lrow <= 32767) ? ((short)(lrow - 1)) : ((short)(lrow - 65536)));
- m_shtNumHorizPageBreaks++;
- m_shtHorizPageBreakRows = (short[])Utils.CopyArray(m_shtHorizPageBreakRows, new short[m_shtNumHorizPageBreaks + 1]);
- m_shtHorizPageBreakRows[m_shtNumHorizPageBreaks] = num;
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- }
- public int WriteValue(ref ValueTypes ValueType, ref int lrow, ref int lcol, object Value)
- {
- CellFont CellFontUsed = CellFont.xlsFont0;
- CellAlignment Alignment = (CellAlignment)120;
- CellHiddenLocked HiddenLocked = CellHiddenLocked.xlsNormal;
- object objectValue = RuntimeHelpers.GetObjectValue(Value);
- int CellFormat = 0;
- return WriteValue(ref ValueType, ref CellFontUsed, ref Alignment, ref HiddenLocked, ref lrow, ref lcol, objectValue, ref CellFormat);
- }
- public int WriteValue(ref ValueTypes ValueType, ref CellAlignment Alignment, ref int lrow, ref int lcol, object Value)
- {
- CellFont CellFontUsed = CellFont.xlsFont0;
- CellHiddenLocked HiddenLocked = CellHiddenLocked.xlsNormal;
- object objectValue = RuntimeHelpers.GetObjectValue(Value);
- int CellFormat = 0;
- return WriteValue(ref ValueType, ref CellFontUsed, ref Alignment, ref HiddenLocked, ref lrow, ref lcol, objectValue, ref CellFormat);
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int WriteValue(ref ValueTypes ValueType, ref CellFont CellFontUsed, ref CellAlignment Alignment, ref CellHiddenLocked HiddenLocked, ref int lrow, ref int lcol, object Value, ref int CellFormat)
- {
- checked
- {
- int result;
- try
- {
- //short row = ((lrow <= 32768) ? ((short)(lrow - 1)) : ((short)(lrow - 65536 - 1)));
- //short col = ((lcol <= 32768) ? ((short)(lcol - 1)) : ((short)(lcol - 65536 - 1)));
- short row = (short)(lrow - 1);
- short col = (short)(lcol - 1);
- switch (ValueType)
- {
- case ValueTypes.xlsInteger:
- {
- tInteger tInteger = default(tInteger);
- tInteger.opcode = 2;
- tInteger.length = 9;
- tInteger.row = row;
- tInteger.col = col;
- tInteger.rgbAttr1 = (byte)HiddenLocked;
- tInteger.rgbAttr2 = (byte)(CellFontUsed + CellFormat);
- tInteger.rgbAttr3 = (byte)Alignment;
- tInteger.intValue = Conversions.ToShort(Value);
- FileSystem.FilePut(m_shtFileNumber, tInteger, -1L);
- break;
- }
- case ValueTypes.xlsNumber:
- {
- tNumber tNumber = default(tNumber);
- tNumber.opcode = 3;
- tNumber.length = 15;
- tNumber.row = row;
- tNumber.col = col;
- tNumber.rgbAttr1 = (byte)HiddenLocked;
- tNumber.rgbAttr2 = (byte)(CellFontUsed + CellFormat);
- tNumber.rgbAttr3 = (byte)Alignment;
- tNumber.NumberValue = Conversions.ToDouble(Value);
- FileSystem.FilePut(m_shtFileNumber, tNumber, -1L);
- break;
- }
- case ValueTypes.xlsText:
- {
- string text = Conversions.ToString(Value);
- short num = (short)GetLength(text);
- tText tText = default(tText);
- tText.opcode = 4;
- tText.length = 10;
- tText.TextLength = (byte)num;
- tText.length = Convert.ToSByte(8 + num);
- tText.row = row;
- tText.col = col;
- tText.rgbAttr1 = (byte)HiddenLocked;
- tText.rgbAttr2 = (byte)(CellFontUsed + CellFormat);
- tText.rgbAttr3 = (byte)Alignment;
- FileSystem.FilePut(m_shtFileNumber, tText, -1L);
- FileSystem.FilePut(m_shtFileNumber, text, -1L);
- break;
- }
- }
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int SetMargin(ref MarginTypes Margin, ref double MarginValue)
- {
- int result;
- try
- {
- MARGIN_RECORD_LAYOUT mARGIN_RECORD_LAYOUT = default(MARGIN_RECORD_LAYOUT);
- mARGIN_RECORD_LAYOUT.opcode = checked((short)Margin);
- mARGIN_RECORD_LAYOUT.length = 8;
- mARGIN_RECORD_LAYOUT.MarginValue = MarginValue;
- FileSystem.FilePut(m_shtFileNumber, mARGIN_RECORD_LAYOUT, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int SetColumnWidth(ref byte FirstColumn, ref byte LastColumn, ref short WidthValue)
- {
- checked
- {
- int result;
- try
- {
- COLWIDTH_RECORD cOLWIDTH_RECORD = default(COLWIDTH_RECORD);
- cOLWIDTH_RECORD.opcode = 36;
- cOLWIDTH_RECORD.length = 4;
- cOLWIDTH_RECORD.col1 = Convert.ToByte(FirstColumn - 1);
- cOLWIDTH_RECORD.col2 = Convert.ToByte(LastColumn - 1);
- cOLWIDTH_RECORD.ColumnWidth = Convert.ToSByte(WidthValue * 256);
- FileSystem.FilePut(m_shtFileNumber, cOLWIDTH_RECORD, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public short SetFont(ref string FontName, ref short FontHeight, ref FontFormatting FontFormat)
- {
- checked
- {
- short result;
- try
- {
- short num = (short)GetLength(FontName);
- FONT_RECORD fONT_RECORD = default(FONT_RECORD);
- fONT_RECORD.opcode = 49;
- fONT_RECORD.length = Convert.ToSByte(5 + num);
- fONT_RECORD.FontHeight = Convert.ToSByte(FontHeight * 20);
- fONT_RECORD.FontAttributes1 = (byte)FontFormat;
- fONT_RECORD.FontAttributes2 = 0;
- fONT_RECORD.FontNameLength = (byte)num;
- FileSystem.FilePut(m_shtFileNumber, fONT_RECORD, -1L);
- FileSystem.FilePut(m_shtFileNumber, FontName, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = (short)Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int SetHeader(ref string HeaderText)
- {
- checked
- {
- int result;
- try
- {
- short num = (short)GetLength(HeaderText);
- HEADER_FOOTER_RECORD hEADER_FOOTER_RECORD = default(HEADER_FOOTER_RECORD);
- hEADER_FOOTER_RECORD.opcode = 20;
- hEADER_FOOTER_RECORD.length = Convert.ToSByte(1 + num);
- hEADER_FOOTER_RECORD.TextLength = (byte)num;
- FileSystem.FilePut(m_shtFileNumber, hEADER_FOOTER_RECORD, -1L);
- FileSystem.FilePut(m_shtFileNumber, HeaderText, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int SetFooter(ref string FooterText)
- {
- checked
- {
- int result;
- try
- {
- short num = (short)GetLength(FooterText);
- HEADER_FOOTER_RECORD hEADER_FOOTER_RECORD = default(HEADER_FOOTER_RECORD);
- hEADER_FOOTER_RECORD.opcode = 21;
- hEADER_FOOTER_RECORD.length = Convert.ToSByte(1 + num);
- hEADER_FOOTER_RECORD.TextLength = (byte)num;
- FileSystem.FilePut(m_shtFileNumber, hEADER_FOOTER_RECORD, -1L);
- FileSystem.FilePut(m_shtFileNumber, FooterText, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int SetFilePassword(ref string PasswordText)
- {
- int result;
- try
- {
- short length = checked((short)GetLength(PasswordText));
- PASSWORD_RECORD pASSWORD_RECORD = default(PASSWORD_RECORD);
- pASSWORD_RECORD.opcode = 47;
- pASSWORD_RECORD.length = length;
- FileSystem.FilePut(m_shtFileNumber, pASSWORD_RECORD, -1L);
- FileSystem.FilePut(m_shtFileNumber, PasswordText, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- private void WriteDefaultFormats()
- {
- string[] array = new string[24];
- string text = "\"";
- array[0] = "General";
- array[1] = "0";
- array[2] = "0.00";
- array[3] = "#,##0";
- array[4] = "#,##0.00";
- array[5] = "#,##0/ " + text + "$" + text + ";/-#,##0/ " + text + "$" + text;
- array[6] = "#,##0/ " + text + "$" + text + ";[Red]/-#,##0/ " + text + "$" + text;
- array[7] = "#,##0.00/ " + text + "$" + text + ";/-#,##0.00/ " + text + "$" + text;
- array[8] = "#,##0.00/ " + text + "$" + text + ";[Red]/-#,##0.00/ " + text + "$" + text;
- array[9] = "0%";
- array[10] = "0.00%";
- array[11] = "0.00E+00";
- array[12] = "dd/mm/yy";
- array[13] = "dd// mmm/ yy";
- array[14] = "dd// mmm";
- array[15] = "mmm/ yy";
- array[16] = "h:mm/ AM/PM";
- array[17] = "h:mm:ss/ AM/PM";
- array[18] = "hh:mm";
- array[19] = "hh:mm:ss";
- array[20] = "dd/mm/yy/ hh:mm";
- array[21] = "##0.0E+0";
- array[22] = "mm:ss";
- array[23] = "@";
- FORMAT_COUNT_RECORD fORMAT_COUNT_RECORD = default(FORMAT_COUNT_RECORD);
- fORMAT_COUNT_RECORD.opcode = 31;
- fORMAT_COUNT_RECORD.length = 2;
- checked
- {
- fORMAT_COUNT_RECORD.Count = (short)Information.UBound(array);
- FileSystem.FilePut(m_shtFileNumber, fORMAT_COUNT_RECORD, -1L);
- int num = Information.LBound(array);
- int num2 = Information.UBound(array);
- FORMAT_RECORD fORMAT_RECORD = default(FORMAT_RECORD);
- for (int i = num; i <= num2; i++)
- {
- int num3 = Strings.Len(array[i]);
- fORMAT_RECORD.opcode = 30;
- fORMAT_RECORD.length = (short)(num3 + 1);
- fORMAT_RECORD.FormatLenght = (byte)num3;
- FileSystem.FilePut(m_shtFileNumber, fORMAT_RECORD, -1L);
- int num4 = 1;
- int num5 = num3;
- for (int j = num4; j <= num5; j++)
- {
- byte value = (byte)Strings.Asc(Strings.Mid(array[i], j, 1));
- FileSystem.FilePut(m_shtFileNumber, value, -1L);
- }
- }
- }
- }
- private static string MKI(ref short x)
- {
- string lpvDest = Strings.Space(2);
- CopyMemory(ref lpvDest, ref x, 2);
- return lpvDest;
- }
- private static int GetLength(string strText)
- {
- return Encoding.Default.GetBytes(strText).Length;
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int SetDefaultRowHeight(int HeightValue)
- {
- int result;
- try
- {
- DEF_ROWHEIGHT_RECORD dEF_ROWHEIGHT_RECORD = default(DEF_ROWHEIGHT_RECORD);
- dEF_ROWHEIGHT_RECORD.opcode = 37;
- dEF_ROWHEIGHT_RECORD.length = 2;
- dEF_ROWHEIGHT_RECORD.RowHeight = checked(HeightValue * 20);
- FileSystem.FilePut(m_shtFileNumber, dEF_ROWHEIGHT_RECORD, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public int SetRowHeight(int Row, short HeightValue)
- {
- checked
- {
- int result;
- try
- {
- int rowNumber = ((Row <= 32767) ? (Row - 1) : (Row - 65536));
- ROW_HEIGHT_RECORD rOW_HEIGHT_RECORD = default(ROW_HEIGHT_RECORD);
- rOW_HEIGHT_RECORD.opcode = 8;
- rOW_HEIGHT_RECORD.length = 16;
- rOW_HEIGHT_RECORD.RowNumber = rowNumber;
- rOW_HEIGHT_RECORD.FirstColumn = 0;
- rOW_HEIGHT_RECORD.LastColumn = 256;
- rOW_HEIGHT_RECORD.RowHeight = HeightValue * 20;
- rOW_HEIGHT_RECORD.@internal = 0;
- rOW_HEIGHT_RECORD.DefaultAttributes = 0;
- rOW_HEIGHT_RECORD.FileOffset = 0;
- rOW_HEIGHT_RECORD.rgbAttr1 = 0;
- rOW_HEIGHT_RECORD.rgbAttr2 = 0;
- rOW_HEIGHT_RECORD.rgbAttr3 = 0;
- FileSystem.FilePut(m_shtFileNumber, rOW_HEIGHT_RECORD, -1L);
- result = 0;
- }
- catch (Exception projectError)
- {
- ProjectData.SetProjectError(projectError);
- result = Information.Err().Number;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- }
- }
- }
|