这根本不是技术问题!!!虽然我这辈子绝对不会对男人有兴趣,但我发现我一定是"爱"上你了,
如果不是的话我怎么会花了一个钟头做一个根本不是技术问题的问题呢。唉……
我也不知道自己到底是为什么,一个聪明的程序员不会为了这根本换不到一分钱的分数
来这样做吧。。。。。。只希望你拿着有用啦。显然我做得比别人差多了。:)
procedure TForm1.Button1Click(Sender: TObject);
Const
Change : Integer = 2;
ColCount : Integer = 3;
RowCount : Integer = 3;
var
MS : Variant;
Arr : Array [1..3] of Variant; // 最大数3和ColCount一起改动
i,j, K:integer;
S, ChangeCell, AllS, BCell :string;
Procedure ABC;
var
K : Integer;
begin
if Copy(S, Length(S) - 1, 1) <> ',' then
S := S + ',';
While S <> '' do
begin
AllS := '';
For K := 1 to ColCount do
if K <> Change then AllS := AllS + VarToStr(Arr[K]) + ' '
else AllS := AllS + BCell + Copy(S, 1, Pos(',',S) - 1) + ' ';
Memo1.Lines.Add(AllS);
Delete(S,1,Pos(',',s));
end;
AllS := '';
end;
Procedure CDE;
var
Starti, Endi, K, L : Integer;
begin
Try
Starti := StrToInt(Copy(S,1,Pos('-',S) - 1));
Endi := StrToInt(Copy(S,Pos('-',S) + 1, Length(S)));
For L := Starti to Endi do
begin
AllS := '';
For K := 1 to ColCount do
if K <> Change then AllS := AllS + VarToStr(Arr[K]) + ' '
else AllS := AllS + BCell + IntToStr(L) + ' ';
Memo1.Lines.Add(AllS);
end;
AllS := '';
Except
ShowMessage('Error');
end;
end;
begin
Memo1.Clear;
Ms := ExcelApp.ActiveWorkBook.ActiveSheet.Range['B12
14']; //这里是你的数据区
For I := 1 to RowCount do
begin
AllS := '';
ChangeCell := VarToStr(Ms.Cells[I, 2].Value);
if Pos('(', ChangeCell) <> 0 then
begin
BCell := Copy(ChangeCell,1,Pos('(', ChangeCell) - 1);
s:='';
For J := 1 to ColCount do Arr[J] := VarToStr(Ms.Cells[I, J].Value);
S := Copy(ChangeCell, Pos('(', ChangeCell) + 1,
Pos(')', ChangeCell) - Pos('(', ChangeCell) - 1);
if Pos(',', ChangeCell) <> 0 then ABC
else if Pos('-', ChangeCell) <> 0 then CDE;
end else
For J := 1 to ColCount do
AllS := AllS + VarToStr(Ms.Cells[I, J].Value) + ' ';
if AllS <> '' then Memo1.Lines.Add(AllS);
end;
Memo1.Lines.SaveToFile('C:/OK.txt'); // 这里是你写入的文件名
end;