- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
public void ConvertCross_2(int ch, string pfile,string NameSheet){
//Преобразуем КроссТаблицу
int Div = Convert.ToInt16(comboBox3.Text) - 1;
string fn = ""; string fn1 = ""; string fn12 = ""; string fn13 = "";
string fn14 = ""; string fn15 = ""; string fn16 = ""; string fn2 = "";
string fn3 = "";
string st = "";
StreamWriter sw;
string dirfile = "";
if (textBox1.Text != ""){
dirfile = textBox1.Text + "\\" + pfile + ".csv";
if (ch == 1){
File.Delete(dirfile);
}
sw = new StreamWriter(dirfile, true, System.Text.Encoding.UTF8);
}else{
if (ch == 1){
File.Delete(openFileDialog1.FileName + ".csv");
}
sw = new StreamWriter(openFileDialog1.FileName + ".csv", true, System.Text.Encoding.UTF8);
}
try{
for (int cl = 0; cl < 3 + Div; cl++){
fn = "F" + cl;
if (cl == 0){
st = fn;
}else{
st += ";" + fn ;
}
}
st += ";" + "Sheets";
if (ch == 1){
sw.WriteLine(st);
}
for (int i = 1 + Div; i < dt.Columns.Count; i++){
Application.DoEvents();
for (int j = 1; j < dt.Rows.Count; j++){
fn1 = dt.Rows[j][0].ToString();
if (fn1 == "") fn1 = " ";
else fn1 = fn1.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
if (Div >= 1){
fn12 = dt.Rows[j][1].ToString();
if (fn1 == "") fn12 = " ";
else fn12 = fn12.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
}
if (Div >= 2){
fn13 = dt.Rows[j][2].ToString();
if (fn13 == "") fn13 = " ";
else fn13 = fn13.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
}
if (Div >= 3){
fn14 = dt.Rows[j][3].ToString();
if (fn14 == "") fn14 = " ";
else fn14 = fn14.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
}
if (Div >= 4){
fn15 = dt.Rows[j][4].ToString();
if (fn15 == "") fn15 = " ";
else fn15 = fn15.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
}
if (Div == 5){
fn16 = dt.Rows[j][5].ToString();
if (fn16 == "") fn16 = " ";
else fn16 = fn16.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
}
fn2 = dt.Rows[0][i].ToString();
if (fn2 == "") fn2 = " ";
else fn2 = fn2.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
fn3 = dt.Rows[j][i].ToString();
if (fn2 == "") fn2 = " ";
else fn2 = fn2.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
st = fn1 + ";";
if (Div >= 1){
st = st + fn12 + ";";
}
if (Div >= 2){
st = st + fn13 + ";";
}
if (Div >= 3){
st = st + fn14 + ";";
}
if (Div >= 4){
st = st + fn15 + ";";
}
if (Div >= 5){
st = st + fn16 + ";";
}
st = st + fn2 + ";" + fn3 + ";\"" + NameSheet.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
if (fn3.Trim()!=""){
sw.WriteLine(st);
}
}
}
sw.Close();
}finally{
sw.Close();
}
}